Skip to content

Commit

Permalink
improve mem
Browse files Browse the repository at this point in the history
  • Loading branch information
xianjimli committed Dec 25, 2023
1 parent 754b906 commit 6fc1e2d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/changes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# 最新动态

2023/12/25
* 完善内存管理,支持直接使用OS提供的函数。

2023/12/24
* 完善data reader
* data\_reader\_http 支持 chunked data
Expand Down
7 changes: 6 additions & 1 deletion src/tkc/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "tkc/mem_allocator_oom.h"
#include "tkc/mem_allocator_pool.h"

#if !defined(WITH_OS_MEM)
static mem_allocator_oom_t s_oom;

#ifdef ENABLE_MEM_LEAK_CHECK
Expand All @@ -33,6 +34,7 @@ static mem_allocator_debug_t s_debug;
#endif /*ENABLE_MEM_LEAK_CHECK*/

static mem_allocator_t* s_allocator = NULL;
#endif /*WITH_OS_MEM*/

#define MAX_BLOCK_SIZE 0xffff0000

Expand Down Expand Up @@ -67,7 +69,7 @@ static mem_allocator_t* mem_allocator_get(void) {
ret_t tk_mem_init_stage2(void) {
return RET_OK;
}

#elif defined(WITH_OS_MEM)
#else /*non std memory manager*/
#include "tkc/mem_allocator_lock.h"
#include "tkc/mem_allocator_composite.h"
Expand Down Expand Up @@ -146,6 +148,7 @@ void* realloc(void* ptr, size_t size) {

#endif /*HAS_STD_MALLOC*/

#if !defined(WITH_OS_MEM)
void* tk_calloc(uint32_t nmemb, uint32_t size, const char* func, uint32_t line) {
void* addr = NULL;
uint32_t total_size = size * nmemb;
Expand Down Expand Up @@ -186,3 +189,5 @@ void tk_mem_dump(void) {

mem_allocator_dump(allocator);
}
#endif /*WITH_OS_MEM*/

0 comments on commit 6fc1e2d

Please sign in to comment.