Browse code

core/mem: q_malloc - use #else with DBG_QM_MALLOC for debug on freed fragments

(cherry picked from commit 764d5be0c44036bb4b86f841588fb0df3b4bb834)
(cherry picked from commit fc90e4c06c5df8c8a9d5cd615923c09a93b5a810)
(cherry picked from commit b95e319d006a38fcc6385d704de82e553f7c2236)

Daniel-Constantin Mierla authored on 26/04/2021 09:22:20 • Henning Westerholt committed on 22/10/2021 11:53:43
Showing 1 changed files
... ...
@@ -509,7 +509,7 @@ void qm_free(void* qmp, void* p)
509 509
 
510 510
 #ifdef DBG_QM_MALLOC
511 511
 	qm_debug_frag(qm, f, file, line);
512
-	if (f->u.is_free){
512
+	if (unlikely(f->u.is_free)){
513 513
 		if(likely(cfg_get(core, core_cfg, mem_safety)==0)) {
514 514
 			LM_CRIT("BUG: freeing already freed pointer (%p),"
515 515
 				" called from %s: %s(%d), first free %s: %s(%ld) - aborting\n",
... ...
@@ -524,12 +524,13 @@ void qm_free(void* qmp, void* p)
524 524
 	}
525 525
 	MDBG("freeing frag. %p alloc'ed from %s: %s(%ld)\n",
526 526
 			f, f->file, f->func, f->line);
527
-#endif
527
+#else
528 528
 	if (unlikely(f->u.is_free)){
529 529
 		LM_INFO("freeing a free fragment (%p/%p) - ignore\n",
530 530
 				f, p);
531 531
 		return;
532 532
 	}
533
+#endif
533 534
 
534 535
 	size=f->size;
535 536
 	qm->used-=size;