Module: kamailio
Branch: master
Commit: a7812ed9e076105fcd483ae74c5a087caa4bf629
URL:
https://github.com/kamailio/kamailio/commit/a7812ed9e076105fcd483ae74c5a087…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2015-09-14T10:22:46+02:00
mem: reintroduced the option to use system malloc if PKG_MALLOC is not defined
---
Modified: mem/pkg.h
---
Diff:
https://github.com/kamailio/kamailio/commit/a7812ed9e076105fcd483ae74c5a087…
Patch:
https://github.com/kamailio/kamailio/commit/a7812ed9e076105fcd483ae74c5a087…
---
diff --git a/mem/pkg.h b/mem/pkg.h
index b2a6c40..dd062bb 100644
--- a/mem/pkg.h
+++ b/mem/pkg.h
@@ -20,6 +20,8 @@
#ifndef _sr_pkg_h_
#define _sr_pkg_h_
+#ifdef PKG_MALLOC
+
#include "memapi.h"
extern sr_pkg_api_t _pkg_root;
@@ -47,4 +49,29 @@ int pkg_init_manager(char *name);
void pkg_destroy_manager(void);
void pkg_print_manager(void);
+#else /*PKG_MALLOC*/
+/* use system allocator */
+# include <stdlib.h>
+# include "memdbg.h"
+# ifdef DBG_SYS_MALLOC
+# define pkg_malloc(s) \
+ ( { void *____v123; ____v123=malloc((s)); \
+ MDBG("malloc %p size %lu end %p (%s:%d)\n", ____v123, (unsigned long)(s),
(char*)____v123+(s), __FILE__, __LINE__);\
+ ____v123; } )
+# define pkg_realloc(p, s) \
+ ( { void *____v123; ____v123=realloc(p, s); \
+ MDBG("realloc %p size %lu end %p (%s:%d)\n", ____v123, (unsigned long)(s),
(char*)____v123+(s), __FILE__, __LINE__);\
+ ____v123; } )
+# define pkg_free(p) do{ MDBG("free %p (%s:%d)\n", (p), __FILE__, __LINE__);
free((p)); }while(0)
+# else
+# define pkg_malloc(s) malloc((s))
+# define pkg_realloc(p, s) realloc((p), (s))
+# define pkg_free(p) free((p))
+# endif
+# define pkg_status() do{}while(0)
+# define pkg_info(mi) do{ memset((mi),0, sizeof(*(mi))); } while(0)
+# define pkg_available() 0
+# define pkg_sums() do{}while(0)
+#endif /*PKG_MALLOC*/
+
#endif