From 330a91441acae76440aa6fc61d611d426d55a80b Mon Sep 17 00:00:00 2001 From: Damjan Adamic Date: Sat, 15 Aug 2015 12:39:27 +0200 Subject: [PATCH] Compilation fixes for Bin Allocator --- radio/src/bin_allocator.cpp | 16 ++++++++-------- radio/src/bin_allocator.h | 10 +++++----- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/radio/src/bin_allocator.cpp b/radio/src/bin_allocator.cpp index f74e351f2..73e847a18 100644 --- a/radio/src/bin_allocator.cpp +++ b/radio/src/bin_allocator.cpp @@ -39,11 +39,11 @@ void * bin_realloc(void * ptr, size_t size) // if it fits in current slot, return it // TODO if new size is smaller, try to relocate in smaller slot if ( slots1.can_fit(ptr, size) ) { - // TRACE("OUR realloc %p[%lu] fits in slot1", ptr, size); FLUSH(); + // TRACE("OUR realloc %p[%lu] fits in slot1", ptr, size); return ptr; } if ( slots2.can_fit(ptr, size) ) { - // TRACE("OUR realloc %p[%lu] fits in slot2", ptr, size); FLUSH(); + // TRACE("OUR realloc %p[%lu] fits in slot2", ptr, size); return ptr; } @@ -51,10 +51,10 @@ void * bin_realloc(void * ptr, size_t size) void * res = bin_malloc(size); if (res == 0) { // we don't have the space, use libc malloc - // TRACE("bin_malloc [%lu] FAILURE", size); FLUSH(); + // TRACE("bin_malloc [%lu] FAILURE", size); res = malloc(size); if (res == 0) { - TRACE("libc malloc [%lu] FAILURE", size); FLUSH(); + TRACE("libc malloc [%lu] FAILURE", size); return 0; } } @@ -73,7 +73,7 @@ void *bin_l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) if (ptr) { // avoid a bunch of NULL pointer free calls if (!bin_free(ptr)) { // not our range, use libc allocator - // TRACE("libc free %p", ptr); FLUSH(); + // TRACE("libc free %p", ptr); free(ptr); } } @@ -89,18 +89,18 @@ void *bin_l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) } if ( SimulateMallocFailure > 0) { // simulate one malloc failure - TRACE("bin_l_alloc(): simulating malloc failure at %p[%lu]", ptr, nsize); FLUSH(); + TRACE("bin_l_alloc(): simulating malloc failure at %p[%lu]", ptr, nsize); return 0; } #endif // #if defined(DEBUG) // try our allocator, if it fails use libc allocator void * res = bin_realloc(ptr, nsize); if (res && ptr) { - // TRACE("OUR realloc %p[%lu] -> %p[%lu]", ptr, osize, res, nsize); FLUSH(); + // TRACE("OUR realloc %p[%lu] -> %p[%lu]", ptr, osize, res, nsize); } if (res == 0) { res = realloc(ptr, nsize); - // TRACE("libc realloc %p[%lu] -> %p[%lu]", ptr, osize, res, nsize); FLUSH(); + // TRACE("libc realloc %p[%lu] -> %p[%lu]", ptr, osize, res, nsize); // if (res == 0 ){ // TRACE("realloc FAILURE %lu", nsize); // dumpFreeMemory(); diff --git a/radio/src/bin_allocator.h b/radio/src/bin_allocator.h index 1c50fb75b..bfb1b7a97 100644 --- a/radio/src/bin_allocator.h +++ b/radio/src/bin_allocator.h @@ -20,7 +20,7 @@ public: if (ptr == Bins[n].data) { Bins[n].Used = false; --NoUsedBins; - // TRACE("\tBinAllocator<%d> free %lu ------", SIZE_SLOT, n); FLUSH(); + // TRACE("\tBinAllocator<%d> free %lu ------", SIZE_SLOT, n); return true; } } @@ -31,22 +31,22 @@ public: } void * malloc(size_t size) { if (size > SIZE_SLOT) { - // TRACE("BinAllocator<%d> malloc [%lu] size > SIZE_SLOT", SIZE_SLOT, size); FLUSH(); + // TRACE("BinAllocator<%d> malloc [%lu] size > SIZE_SLOT", SIZE_SLOT, size); return 0; } if (NoUsedBins >= NUM_BINS) { - // TRACE("BinAllocator<%d> malloc [%lu] no free slots", SIZE_SLOT, size); FLUSH(); + // TRACE("BinAllocator<%d> malloc [%lu] no free slots", SIZE_SLOT, size); return 0; } for (size_t n = 0; n < NUM_BINS; ++n) { if (!Bins[n].Used) { Bins[n].Used = true; ++NoUsedBins; - // TRACE("\tBinAllocator<%d> malloc %lu[%lu]", SIZE_SLOT, n, size); FLUSH(); + // TRACE("\tBinAllocator<%d> malloc %lu[%lu]", SIZE_SLOT, n, size); return Bins[n].data; } } - // TRACE("BinAllocator<%d> malloc [%lu] no free slots", SIZE_SLOT , size); FLUSH(); + // TRACE("BinAllocator<%d> malloc [%lu] no free slots", SIZE_SLOT , size); return 0; } size_t size(void * ptr) {