Browse code

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 authored on 26/11/2012 13:14:37
Showing 1 changed files
... ...
@@ -488,8 +488,8 @@ void qm_free(struct qm_block* qm, void* p)
488 488
 		f->u.nxt_free=(void*)0x1L; /* bogus value, just to mark it as free */
489 489
 		/* join packets if possible*/
490 490
 		next=FRAG_NEXT(f);
491
-		if (((char*)next < (char*)qm->last_frag_end) &&( next->u.is_free)){
492
-		/* join */
491
+		if (((char*)next < (char*)qm->last_frag_end) && (next->u.is_free)){
492
+			/* join next packet */
493 493
 #ifdef DBG_QM_MALLOC
494 494
 			qm_debug_frag(qm, next);
495 495
 #endif
... ...
@@ -503,15 +503,15 @@ void qm_free(struct qm_block* qm, void* p)
503 503
 			prev=FRAG_PREV(f);
504 504
 			/*	(struct qm_frag*)((char*)f - (struct qm_frag_end*)((char*)f-
505 505
 								sizeof(struct qm_frag_end))->size);*/
506
+			if (prev->u.is_free){
507
+				/* join prev packet */
506 508
 #ifdef DBG_QM_MALLOC
507
-			qm_debug_frag(qm, prev);
509
+				qm_debug_frag(qm, prev);
508 510
 #endif
509
-			if (prev->u.is_free){
510
-				/*join*/
511 511
 				qm_detach_free(qm, prev);
512 512
 				size+=prev->size+FRAG_OVERHEAD;
513 513
 				qm->real_used-=FRAG_OVERHEAD;
514
-					qm->free_hash[GET_HASH(prev->size)].no--; /* FIXME slow */
514
+				qm->free_hash[GET_HASH(prev->size)].no--; /* FIXME slow */
515 515
 				f=prev;
516 516
 			}
517 517
 		}