Module: kamailio
Branch: master
Commit: 48288db22e64a31ba8e3d599aee56d9c4c123d93
URL:
https://github.com/kamailio/kamailio/commit/48288db22e64a31ba8e3d599aee56d9…
Author: Camille Oudot <camille.oudot(a)orange.com>
Committer: Stefan Mititelu <stefan.mititelu(a)1and1.ro>
Date: 2015-04-28T08:46:37+03:00
mem: TLSF integration for pkg memory
---
Modified: mem/mem.c
Modified: mem/mem.h
---
Diff:
https://github.com/kamailio/kamailio/commit/48288db22e64a31ba8e3d599aee56d9…
Patch:
https://github.com/kamailio/kamailio/commit/48288db22e64a31ba8e3d599aee56d9…
---
diff --git a/mem/mem.c b/mem/mem.c
index ac7ddc8..18fb9af 100644
--- a/mem/mem.c
+++ b/mem/mem.c
@@ -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
@@ -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);
diff --git a/mem/mem.h b/mem/mem.h
index d90fcf4..9db8d93 100644
--- a/mem/mem.h
+++ b/mem/mem.h
@@ -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;
@@ -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))
@@ -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)