Skip to content

Commit

Permalink
fix: refine codes
Browse files Browse the repository at this point in the history
  • Loading branch information
halajohn committed Nov 7, 2024
1 parent db8ed53 commit 21e16bf
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
"env": {
"LD_LIBRARY_PATH": "${workspaceFolder}/out/linux/x64/tests/standalone/",
"ASAN_OPTIONS": "abort_on_error=1",
"TEN_ENABLE_MEMORY_TRACKING": "true"
// "TEN_ENABLE_MEMORY_TRACKING": "true"
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion core/include/ten_utils/lib/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "ten_utils/macro/check.h"

#define TEN_STRING_SIGNATURE 0x178445C0402E320DU
#define TEN_STRING_PRE_BUF_SIZE 256
#define TEN_STRING_PRE_BUF_SIZE 1024

typedef struct ten_list_t ten_list_t;

Expand Down
2 changes: 2 additions & 0 deletions core/src/ten_utils/lib/sys/general/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,13 @@ void ten_string_reserve(ten_string_t *self, size_t extra) {
if (self->buf == self->pre_buf) {
tmp = (char *)TEN_MALLOC(new_size);
TEN_ASSERT(tmp, "Failed to allocate memory.");

memcpy(tmp, self->buf, self->first_unused_idx);
} else {
tmp = (char *)TEN_REALLOC(self->buf, new_size);
TEN_ASSERT(tmp, "Failed to allocate memory.");
}

self->buf = tmp;
self->buf_size = new_size;
}
Expand Down
7 changes: 6 additions & 1 deletion core/src/ten_utils/sanitizer/memory_check.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,10 +406,15 @@ void *ten_sanitizer_memory_realloc(void *addr, size_t size,
self, size, file_name, lineno, func_name);
if (!record) {
ten_free(self);
ten_sanitizer_memory_record_del(&g_memory_records, addr);
if (addr != NULL) {
ten_sanitizer_memory_record_del(&g_memory_records, addr);
}
return NULL;
}

if (addr != NULL) {
ten_sanitizer_memory_record_del(&g_memory_records, addr);
}
ten_sanitizer_memory_record_add(&g_memory_records, record);
}

Expand Down
1 change: 1 addition & 0 deletions core/src/ten_utils/value/value_set.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "include_internal/ten_utils/value/value_set.h"

#include "ten_utils/container/list.h"
#include "ten_utils/lib/string.h"
#include "ten_utils/macro/check.h"
#include "ten_utils/value/type.h"
#include "ten_utils/value/value.h"
Expand Down

0 comments on commit 21e16bf

Please sign in to comment.