Skip to content

Commit

Permalink
mem: TLSF integration for pkg memory
Browse files Browse the repository at this point in the history
  • Loading branch information
camilleoudot committed Apr 23, 2015
1 parent 144da7f commit 63b7c71
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions mem/mem.c
Expand Up @@ -51,6 +51,8 @@
struct fm_block* mem_block = 0;
#elif defined DL_MALLOC
/* don't need this */
#elif defined TLSF_MALLOC
tlsf_t mem_block = 0;
#else
struct qm_block* mem_block = 0;
#endif
Expand All @@ -75,6 +77,8 @@ int init_pkg_mallocs(void)
mem_block=fm_malloc_init(mem_pool, pkg_mem_size, MEM_TYPE_PKG);
#elif DL_MALLOC
/* don't need this */
#elif TLSF_MALLOC
mem_block = tlsf_create_with_pool(mem_pool, pkg_mem_size);
#else
if (mem_pool)
mem_block=qm_malloc_init(mem_pool, pkg_mem_size, MEM_TYPE_PKG);
Expand Down
12 changes: 12 additions & 0 deletions mem/mem.h
Expand Up @@ -57,6 +57,9 @@
extern struct fm_block* mem_block;
# elif defined DL_MALLOC
# include "dl_malloc.h"
# elif defined TLSF_MALLOC
# include "tlsf.h"
extern tlsf_t mem_block;
# else
# include "q_malloc.h"
extern struct qm_block* mem_block;
Expand Down Expand Up @@ -92,6 +95,10 @@
# define pkg_malloc(s) dlmalloc((s))
# define pkg_realloc(p, s) dlrealloc((p), (s))
# define pkg_free(p) dlfree((p))
# elif defined TLSF_MALLOC
# define pkg_malloc(s) tlsf_malloc(mem_block, (s))
# define pkg_realloc(p, s) tlsf_realloc(mem_block, (p), (s))
# define pkg_free(p) tlsf_free(mem_block, (p))
# else
# define pkg_malloc(s) qm_malloc(mem_block, (s))
# define pkg_realloc(p, s) qm_realloc(mem_block, (p), (s))
Expand All @@ -108,6 +115,11 @@
# define pkg_info(mi) 0
# define pkg_available() 0
# define pkg_sums() 0
# elif defined TLSF_MALLOC
# define pkg_status() ((void) 0)
# define pkg_info(mi) tlsf_meminfo(mem_block, (mi))
# define pkg_available() ((void) 0)
# define pkg_sums() ((void) 0)
# else
# define pkg_status() qm_status(mem_block)
# define pkg_info(mi) qm_info(mem_block, mi)
Expand Down

0 comments on commit 63b7c71

Please sign in to comment.