Skip to content

Commit

Permalink
core/heap.disabled: rip out HEAP_DEBUG code
Browse files Browse the repository at this point in the history
There's little point in basically just reporting the equivalent of
malloc()/free() each time it happens; there isn't really anything to
debug here.

This also fixes a bug introduced in 101e46d; the HEAP_DEBUG code had
not been properly adjusted and still referenced a variable removed in
that commit, thus breaking compilation with HEAP_DEBUG enabled.
  • Loading branch information
ilbelkyr committed Feb 23, 2021
1 parent 101e46d commit ffc46e5
Showing 1 changed file with 0 additions and 27 deletions.
27 changes: 0 additions & 27 deletions src/libmowgli/core/heap.disabled.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,13 @@ mowgli_heap_create_full(const size_t elem_size,
mowgli_heap_t *const heap = allocator->allocate(sizeof *heap);

if (! heap)
{
#ifdef HEAP_DEBUG
(void) mowgli_log_warning("cannot allocate memory for heap");
#endif
return NULL;
}

(void) memset(heap, 0x00, sizeof *heap);

heap->allocator = allocator;
heap->elem_size = elem_size;

#ifdef HEAP_DEBUG
(void) mowgli_log("pseudoheap@%p: created (elem_size %zu)", heap, elem_size);
#endif

return heap;
}

Expand All @@ -84,10 +75,6 @@ mowgli_heap_destroy(mowgli_heap_t *const restrict heap)
return_if_fail(heap->allocator->deallocate != NULL);

(void) heap->allocator->deallocate(heap);

#ifdef HEAP_DEBUG
(void) mowgli_log("pseudoheap@%p: destroyed (elem_size %zu)", heap, elem_size);
#endif
}

void *
Expand All @@ -101,16 +88,7 @@ mowgli_heap_alloc(mowgli_heap_t *const restrict heap)
void *ptr = heap->allocator->allocate(heap->elem_size);

if (!ptr)
{
#ifdef HEAP_DEBUG
(void) mowgli_log_warning("pseudoheap@%p: cannot allocate memory for ptr", heap);
#endif
return NULL;
}

#ifdef HEAP_DEBUG
(void) mowgli_log("pseudoheap@%p: allocated ptr %p (elem_size %zu)", heap, block->ptr, heap->elem_size);
#endif

return memset(ptr, 0x00, heap->elem_size);
}
Expand All @@ -123,10 +101,5 @@ mowgli_heap_free(mowgli_heap_t *const restrict heap, void *const restrict ptr)
return_if_fail(heap->allocator->deallocate != NULL);
return_if_fail(ptr != NULL);

#ifdef HEAP_DEBUG
(void) mowgli_log("pseudoheap@%p: freeing ptr %p (elem_size %zu)",
heap, ptr, heap->elem_size);
#endif

(void) heap->allocator->deallocate(ptr);
}

0 comments on commit ffc46e5

Please sign in to comment.