瀏覽代碼

Merge branch 'master' of ssh://git.sip-router.org/sip-router

Alex Balashov 13 年之前
父節點
當前提交
76885b5c67
共有 2 個文件被更改,包括 24 次插入11 次删除
  1. 18 5
      Makefile.defs
  2. 6 6
      mem/q_malloc.c

+ 18 - 5
Makefile.defs

@@ -162,11 +162,15 @@ INSTALL_FLAVOUR=$(FLAVOUR)
 VERSION = 3
 PATCHLEVEL = 4
 SUBLEVEL =  0
-EXTRAVERSION = -dev5
+EXTRAVERSION = -dev6
 
+# memory manager switcher
+# 0 - f_malloc (fast malloc)
+# 1 - q_malloc (quick malloc)
+MEMMNG ?= 1
 # memory debugger switcher
-# 0 - off (release mode)
-# 1 - on (devel mode)
+# 0 - off (no-debug mode)
+# 1 - on (debug mode)
 MEMDBG ?= 0
 
 SER_VER = $(shell expr $(VERSION) \* 1000000 + $(PATCHLEVEL) \* 1000 + \
@@ -712,13 +716,22 @@ C_DEFS= $(extra_defs) \
 # use make mode=debug all instead. Anyway no by default ser is  compiled w/ 
 # debugging symbols in all cases (-g). --andrei
 
-ifeq ($(MEMDBG), 1)
-	C_DEFS+= -DDBG_QM_MALLOC
+# set memory manager and its debug mode
+ifeq ($(MEMMNG), 1)
+#	use q_malloc
+ifeq 	($(MEMDBG), 1)
+		C_DEFS+= -DDBG_QM_MALLOC
+endif
 	C_DEFS+= -DMEM_JOIN_FREE
 else
+#	use f_malloc
 	C_DEFS+= -DF_MALLOC
+ifeq 	($(MEMDBG), 1)
+		C_DEFS+= -DDBG_F_MALLOC
+endif
 	C_DEFS+= -DMEM_JOIN_FREE
 endif
+
 ifneq ($(PKG_MEM_SIZE),)
 	C_DEFS+= -DPKG_MEM_SIZE=$(PKG_MEM_SIZE)
 endif

+ 6 - 6
mem/q_malloc.c

@@ -488,8 +488,8 @@ void qm_free(struct qm_block* qm, void* p)
 		f->u.nxt_free=(void*)0x1L; /* bogus value, just to mark it as free */
 		/* join packets if possible*/
 		next=FRAG_NEXT(f);
-		if (((char*)next < (char*)qm->last_frag_end) &&( next->u.is_free)){
-		/* join */
+		if (((char*)next < (char*)qm->last_frag_end) && (next->u.is_free)){
+			/* join next packet */
 #ifdef DBG_QM_MALLOC
 			qm_debug_frag(qm, next);
 #endif
@@ -503,15 +503,15 @@ void qm_free(struct qm_block* qm, void* p)
 			prev=FRAG_PREV(f);
 			/*	(struct qm_frag*)((char*)f - (struct qm_frag_end*)((char*)f-
 								sizeof(struct qm_frag_end))->size);*/
+			if (prev->u.is_free){
+				/* join prev packet */
 #ifdef DBG_QM_MALLOC
-			qm_debug_frag(qm, prev);
+				qm_debug_frag(qm, prev);
 #endif
-			if (prev->u.is_free){
-				/*join*/
 				qm_detach_free(qm, prev);
 				size+=prev->size+FRAG_OVERHEAD;
 				qm->real_used-=FRAG_OVERHEAD;
-					qm->free_hash[GET_HASH(prev->size)].no--; /* FIXME slow */
+				qm->free_hash[GET_HASH(prev->size)].no--; /* FIXME slow */
 				f=prev;
 			}
 		}