소스 검색

mem: check debug info only when joining the next packet

- it was checked even it was not freeand not the case for a join
Daniel-Constantin Mierla 12 년 전
부모
커밋
cceb39f9fb
1개의 변경된 파일6개의 추가작업 그리고 6개의 파일을 삭제
  1. 6 6
      mem/q_malloc.c

+ 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;
 			}
 		}