Module: sip-router
Branch: master
Commit: 85f2302e8448ee20edb12bc3b4e2911ca3b111ec
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=85f2302…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Mon Jun 29 12:34:08 2009 +0200
lib/kmi: option to build it with system malloc
- MI lib can be built independently of core with system malloc for pkg
memory (see Makefile)
---
lib/kmi/Makefile | 2 ++
lib/kmi/attr.c | 6 +++---
lib/kmi/fmt.c | 4 ++--
lib/kmi/mi.c | 4 ++--
lib/kmi/tree.c | 11 +++++------
5 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/lib/kmi/Makefile b/lib/kmi/Makefile
index 9a70acf..a20f006 100644
--- a/lib/kmi/Makefile
+++ b/lib/kmi/Makefile
@@ -4,6 +4,8 @@ NAME:=kmi
MAJOR_VER=1
MINOR_VER=0
BUGFIX_VER=0
+## uncomment next line for using system malloc with MI
+#DEFS+= -DMI_SYSTEM_MALLOC
LIBS=
include ../../Makefile.libs
diff --git a/lib/kmi/attr.c b/lib/kmi/attr.c
index 1f254d0..4a1b81b 100644
--- a/lib/kmi/attr.c
+++ b/lib/kmi/attr.c
@@ -36,8 +36,8 @@
#include <string.h>
#include <errno.h>
-#include "../../mem/mem.h"
#include "../../dprint.h"
+#include "mi_mem.h"
#include "attr.h"
#include "fmt.h"
@@ -75,7 +75,7 @@ struct mi_attr *add_mi_attr(struct mi_node *node, int flags,
size_mem += value_len;
}
- new = (struct mi_attr *)pkg_malloc(size_mem);
+ new = (struct mi_attr *)mi_malloc(size_mem);
if (!new) {
LM_ERR("no more pkg mem (%d)\n",size_mem);
return NULL;
@@ -167,7 +167,7 @@ void del_mi_attr_list(struct mi_node *node)
for(head = node->attributes; head ;){
p = head->next;
- pkg_free(head);
+ mi_free(head);
head = p;
}
diff --git a/lib/kmi/fmt.c b/lib/kmi/fmt.c
index 81ca917..a3b8b8f 100644
--- a/lib/kmi/fmt.c
+++ b/lib/kmi/fmt.c
@@ -34,7 +34,7 @@
#include <string.h>
#include "../../dprint.h"
-#include "../../mem/mem.h"
+#include "mi_mem.h"
char *mi_fmt_buf = 0;
int mi_fmt_buf_len = 0;
@@ -42,7 +42,7 @@ int mi_fmt_buf_len = 0;
int mi_fmt_init( unsigned int size )
{
- mi_fmt_buf = (char*)pkg_malloc(size);
+ mi_fmt_buf = (char*)mi_malloc(size);
if (mi_fmt_buf==NULL) {
LM_ERR("no more pkg mem\n");
return -1;
diff --git a/lib/kmi/mi.c b/lib/kmi/mi.c
index 6dfa709..dfa458e 100644
--- a/lib/kmi/mi.c
+++ b/lib/kmi/mi.c
@@ -46,7 +46,7 @@
#include <string.h>
#include "../../dprint.h"
-#include "../../mem/mem.h"
+#include "mi_mem.h"
#include "mi.h"
static struct mi_cmd* mi_cmds = 0;
@@ -138,7 +138,7 @@ int register_mi_cmd( mi_cmd_f f, char *name, void *param,
return -1;
}
- cmds = (struct mi_cmd*)pkg_realloc( mi_cmds,
+ cmds = (struct mi_cmd*)mi_realloc( mi_cmds,
(mi_cmds_no+1)*sizeof(struct mi_cmd) );
if (cmds==0) {
LM_ERR("no more pkg memory\n");
diff --git a/lib/kmi/tree.c b/lib/kmi/tree.c
index 4ca6578..da29fea 100644
--- a/lib/kmi/tree.c
+++ b/lib/kmi/tree.c
@@ -34,9 +34,8 @@
#include <string.h>
#include <stdio.h>
#include <errno.h>
-#include "../../mem/mem.h"
-#include "../../mem/shm_mem.h"
#include "../../dprint.h"
+#include "mi_mem.h"
#include "tree.h"
#include "fmt.h"
@@ -50,7 +49,7 @@ struct mi_root *init_mi_tree(unsigned int code, char *reason, int
reason_len)
if (use_shm)
root = (struct mi_root *)shm_malloc(sizeof(struct mi_root));
else
- root = (struct mi_root *)pkg_malloc(sizeof(struct mi_root));
+ root = (struct mi_root *)mi_malloc(sizeof(struct mi_root));
if (!root) {
LM_ERR("no more pkg mem\n");
return NULL;
@@ -83,7 +82,7 @@ static void free_mi_node(struct mi_node *parent)
shm_free(parent);
} else {
del_mi_attr_list(parent);
- pkg_free(parent);
+ mi_free(parent);
}
}
@@ -100,7 +99,7 @@ void free_mi_tree(struct mi_root *parent)
if (use_shm)
shm_free(parent);
else
- pkg_free(parent);
+ mi_free(parent);
}
@@ -135,7 +134,7 @@ static inline struct mi_node *create_mi_node(char *name, int
name_len,
if (use_shm)
new = (struct mi_node *)shm_malloc(size_mem);
else
- new = (struct mi_node *)pkg_malloc(size_mem);
+ new = (struct mi_node *)mi_malloc(size_mem);
if(!new) {
LM_ERR("no more pkg mem\n");
return NULL;