-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
norm: resolve memory allocator norm issues
- Loading branch information
1 parent
4dc9788
commit 48c2010
Showing
7 changed files
with
32 additions
and
230 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,36 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* allocator.h :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: hamza <hamza@student.42.fr> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/03/25 15:17:28 by hamza #+# #+# */ | ||
/* Updated: 2024/03/25 15:20:02 by hamza ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#ifndef ALLOCATOR_H | ||
# define ALLOCATOR_H | ||
|
||
# ifndef TESTER_MODE | ||
# define TESTER_MODE 0 | ||
# endif | ||
|
||
# if TESTER_MODE | ||
# include "tester.h" | ||
# define ALLOCATE_MEMORY fake_malloc | ||
# define FREE_MEMORY fake_free | ||
# else | ||
# define ALLOCATE_MEMORY malloc | ||
# define FREE_MEMORY free | ||
# endif | ||
|
||
/* | ||
A struct to store memory blocks which allocated | ||
by using malloc function. | ||
Yes, it is a linked list. | ||
*/ | ||
typedef struct s_memory_block { | ||
void *ptr; | ||
struct s_memory_block *next; | ||
} t_memory_block; | ||
typedef struct s_memory_block | ||
{ | ||
void *ptr; | ||
struct s_memory_block *next; | ||
} t_memory_block; | ||
|
||
void *safe_malloc(int size); | ||
void safe_free(void *ptr); | ||
t_memory_block *get_memory_blocks(void); | ||
void free_memory(void); | ||
void abort_memory(void); | ||
void register_pre_abort_func(void (*abort_func)(void)); | ||
void register_post_abort_func(void (*abort_func)(void)); | ||
void register_pre_abort_func(void (*abort_func)(void)); | ||
void register_post_abort_func(void (*abort_func)(void)); | ||
|
||
#endif |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.