diff --git a/src/block.c b/src/block.c index 60c8d15..1209898 100644 --- a/src/block.c +++ b/src/block.c @@ -9,6 +9,7 @@ #include "align.h" #include "chunk.h" #include "chunk_manager.h" +#include "malloc.h" int add_new_block(chunk_t* chunk, size_t size, void *prev, bool is_used) { @@ -19,7 +20,7 @@ int add_new_block(chunk_t* chunk, size_t size, void *prev, bool is_used) // TODO check with getrlimit() new_block = mmap(NULL, size + ALIGN_MARGING + HEADER_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); -#ifndef DEBUG +#ifdef DEBUG if (new_block == NULL) write(2, "mmap failed\n", 12); #endif diff --git a/src/chunk_manager.c b/src/chunk_manager.c index 192769c..054319d 100644 --- a/src/chunk_manager.c +++ b/src/chunk_manager.c @@ -3,12 +3,13 @@ #include "raw_chunk_manager.h" #include "print.h" #include "block.h" +#include "malloc.h" #include void chunk_merge(chunk_t *first, chunk_t *second) { -#ifndef DEBUG +#ifdef DEBUG if (first->block_id != second->block_id) write(2, "Attempt merge two chunk on different block\n", 43); #endif @@ -22,7 +23,7 @@ int chunk_split(chunk_t *chunk, size_t new_size) { chunk_t new_chunk; -#ifndef DEBUG +#ifdef DEBUG if (chunk->size + 1 < new_size + HEADER_SIZE + get_align_increment(chunk->current + HEADER_SIZE)) write(2, "chunk too small to be splitted\n", 31); #endif diff --git a/src/free.c b/src/free.c index 1b22556..472a4ff 100644 --- a/src/free.c +++ b/src/free.c @@ -57,7 +57,7 @@ void ft_free(void *ptr) for (i = TINY; i <= LARGE + 1; i++) { -#ifndef DEBUG +#ifdef DEBUG if (i > LARGE) write(2, "chunk not found\n", 16); #endif @@ -72,7 +72,7 @@ void ft_free(void *ptr) chunk_read(raw_chunk, &chunk); -#ifndef DEBUG +#ifdef DEBUG if (chunk.is_used == false) write(2, "double free\n", 12); #endif