fix: use ifdef instead ifndef
This commit is contained in:
		@ -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
 | 
			
		||||
 | 
			
		||||
@ -3,12 +3,13 @@
 | 
			
		||||
#include "raw_chunk_manager.h"
 | 
			
		||||
#include "print.h"
 | 
			
		||||
#include "block.h"
 | 
			
		||||
#include "malloc.h"
 | 
			
		||||
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user