[sr-dev] git:master:63b7c711: mem: TLSF integration for pkg memory

Camille Oudot camille.oudot at orange.com
Fri Apr 24 11:49:14 CEST 2015


Module: kamailio
Branch: master
Commit: 63b7c711c26557b7caafb76b98a89e6b28ec3593
URL: https://github.com/kamailio/kamailio/commit/63b7c711c26557b7caafb76b98a89e6b28ec3593

Author: Camille Oudot <camille.oudot at orange.com>
Committer: Camille Oudot <camille.oudot at orange.com>
Date: 2015-04-23T17:28:18+02:00

mem: TLSF integration for pkg memory

---

Modified: mem/mem.c
Modified: mem/mem.h

---

Diff:  https://github.com/kamailio/kamailio/commit/63b7c711c26557b7caafb76b98a89e6b28ec3593.diff
Patch: https://github.com/kamailio/kamailio/commit/63b7c711c26557b7caafb76b98a89e6b28ec3593.patch

---

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)




More information about the sr-dev mailing list