Functions to simulate a garbage.
More...
Functions to simulate a garbage.
◆ add_to_garbage()
void add_to_garbage |
( |
t_garbage * | garbage, |
|
|
void * | ptr ) |
Add a pointer to the garbage list.
- Parameters
-
garbage | garbage structure |
ptr | pointer to add |
◆ free_element_gb()
void free_element_gb |
( |
t_garbage * | garbage, |
|
|
void * | ptr ) |
Free an element in the garbage collector.
- Parameters
-
garbage | garbage structure |
ptr | element to free |
◆ free_garbage()
◆ ft_garbageadd_back()
Adds the 'new' element at the end of stack.
- Deprecated
- not used anywhere as add_front is faster
- Parameters
-
garbage | garbage structure |
new | element to add |
◆ ft_garbageadd_front()
Adds the 'new' element at the start of stack.
- Parameters
-
garbage | garbage structure |
new | element to add |
◆ ft_garbageclear()
Remove all elements from garbage.
- Parameters
-
- Returns
- int 0 OK, -1 is error
◆ ft_garbagenew()
Allocates and returns the newly created element 'value' is initialised with content 'next' is set to NULL.
- Parameters
-
ptr | pointer to add in the element |
- Returns
- t_element* pointer to the element
◆ ft_strdup_gb()
char * ft_strdup_gb |
( |
t_garbage * | garbage, |
|
|
const char * | source ) |
Create a copy of source into a new pointer NEEDS to be freed.
- Parameters
-
garbage | garbage structure |
source | string to copy |
- Returns
- char* pointer to the new string
◆ garbage_init()
Get the garbage object.
- Returns
- t_garbage* garbage access
Initialize the garbage and sets the values to 0
◆ malloc_gb()
void * malloc_gb |
( |
t_garbage * | garbage, |
|
|
size_t | size ) |
Replace the original malloc by storing the created adresses into a garbage to remove them afterwards.
- Parameters
-
garbage | garbage structure |
size | number of bytes to allocates |
- Returns
- void*
◆ print_garbage()
Print the garbage collector.