|
@@ -27,7 +27,9 @@
|
|
|
#include "other.h"
|
|
|
#include "sys_alloc.h"
|
|
|
#include "block_header.h"
|
|
|
+#ifdef WITH_STATS
|
|
|
#include "print_stats.h"
|
|
|
+#endif /* WITH_STATS */
|
|
|
|
|
|
void *sys_alloc(allocator_t *allocator, heap_t *heap, size_t size) {
|
|
|
|
|
@@ -81,7 +83,9 @@ void *sys_alloc(allocator_t *allocator, heap_t *heap, size_t size) {
|
|
|
allocator->remaining_size -= allocation_size;
|
|
|
} else {
|
|
|
printf("No more free space.\n");
|
|
|
+#ifdef WITH_STATS
|
|
|
print_stats(allocator);
|
|
|
+#endif /* WITH_STATS */
|
|
|
return NULL;
|
|
|
}
|
|
|
#endif /* WITH_MEMORY_SPACE_AWARENESS */
|
|
@@ -103,11 +107,13 @@ void *sys_alloc(allocator_t *allocator, heap_t *heap, size_t size) {
|
|
|
/* Update the used blocks list */
|
|
|
push_block(ptr, heap->used_blocks_head);
|
|
|
|
|
|
+#ifdef WITH_STATS
|
|
|
/* Update statistics */
|
|
|
heap->dmm_stats.mem_allocated += req_padding(size);
|
|
|
heap->dmm_stats.mem_requested += size;
|
|
|
heap->dmm_stats.live_objects += 1;
|
|
|
heap->dmm_stats.num_malloc += 1;
|
|
|
+#endif /* WITH_STATS */
|
|
|
|
|
|
/* FIXME To be refactored - END */
|
|
|
|