diff --git a/easylogger/inc/elog.h b/easylogger/inc/elog.h index 85801f0..fd81886 100644 --- a/easylogger/inc/elog.h +++ b/easylogger/inc/elog.h @@ -50,7 +50,7 @@ extern "C" { #define ELOG_LVL_TOTAL_NUM 6 /* EasyLogger software version number */ -#define ELOG_SW_VERSION "1.11.25" +#define ELOG_SW_VERSION "1.12.19" /* EasyLogger assert for developer. */ #ifdef ELOG_ASSERT_ENABLE @@ -206,6 +206,7 @@ size_t elog_async_get_line_log(char *log, size_t size); /* elog_utils.c */ size_t elog_strcpy(size_t cur_len, char *dst, const char *src); size_t elog_cpyln(char *line, const char *log, size_t len); +void *elog_memcpy(void *dst, const void *src, size_t count); #ifdef __cplusplus } diff --git a/easylogger/plugins/flash/elog_flash.c b/easylogger/plugins/flash/elog_flash.c index caf61cf..a75bda1 100644 --- a/easylogger/plugins/flash/elog_flash.c +++ b/easylogger/plugins/flash/elog_flash.c @@ -179,7 +179,7 @@ void elog_flash_write(const char *log, size_t size) { while (true) { if (cur_buf_size + size > ELOG_FLASH_BUF_SIZE) { write_size = ELOG_FLASH_BUF_SIZE - cur_buf_size; - memcpy(log_buf + cur_buf_size, log + write_index, write_size); + elog_memcpy(log_buf + cur_buf_size, log + write_index, write_size); write_index += write_size; size -= write_size; cur_buf_size += write_size; @@ -190,7 +190,7 @@ void elog_flash_write(const char *log, size_t size) { /* lock flash log buffer */ log_buf_lock(); } else { - memcpy(log_buf + cur_buf_size, log + write_index, size); + elog_memcpy(log_buf + cur_buf_size, log + write_index, size); cur_buf_size += size; break; } @@ -202,7 +202,7 @@ void elog_flash_write(const char *log, size_t size) { result = ef_log_write((uint32_t *) log, write_size_temp); /* write last word alignment data */ if ((result == EF_NO_ERR) && (write_size_temp != size)) { - memcpy(write_overage_c, log + write_size_temp, size - write_size_temp); + elog_memcpy(write_overage_c, log + write_size_temp, size - write_size_temp); ef_log_write((uint32_t *) write_overage_c, 4); } #endif diff --git a/easylogger/plugins/flash/elog_flash.h b/easylogger/plugins/flash/elog_flash.h index 60f2c46..5300b22 100644 --- a/easylogger/plugins/flash/elog_flash.h +++ b/easylogger/plugins/flash/elog_flash.h @@ -41,7 +41,7 @@ extern "C" { #endif /* EasyLogger flash log plugin's software version number */ -#define ELOG_FLASH_SW_VERSION "1.10.11" +#define ELOG_FLASH_SW_VERSION "1.12.19" /* elog_flash.c */ ElogErrCode elog_flash_init(void); diff --git a/easylogger/src/elog_utils.c b/easylogger/src/elog_utils.c index c4f9754..3817d7e 100644 --- a/easylogger/src/elog_utils.c +++ b/easylogger/src/elog_utils.c @@ -80,8 +80,8 @@ size_t elog_strcpy(size_t cur_len, char *dst, const char *src) { size_t elog_cpyln(char *line, const char *log, size_t len) { size_t newline_len = strlen(ELOG_NEWLINE_SIGN), copy_size = 0; - assert(log); assert(line); + assert(log); while (len--) { *line++ = *log++; @@ -92,3 +92,25 @@ size_t elog_cpyln(char *line, const char *log, size_t len) { } return copy_size; } + +/** + * This function will copy memory content from source address to destination + * address. + * + * @param dst the address of destination memory + * @param src the address of source memory + * @param count the copied length + * + * @return the address of destination memory + */ +void *elog_memcpy(void *dst, const void *src, size_t count) { + char *tmp = (char *) dst, *s = (char *) src; + + assert(dst); + assert(src); + + while (count--) + *tmp++ = *s++; + + return dst; +}