Compilation fixes for Bin Allocator
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user