Minishell
 
Loading...
Searching...
No Matches
Garbage functions

Functions to simulate a garbage. More...

Functions

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.
 
void add_to_garbage (t_garbage *garbage, void *ptr)
 Add a pointer to the garbage list.
 
void free_element_gb (t_garbage *garbage, void *ptr)
 Free an element in the garbage collector.
 
char * ft_strdup_gb (t_garbage *garbage, const char *source)
 Create a copy of source into a new pointer NEEDS to be freed.
 
void garbage_init (t_garbage *garbage)
 Get the garbage object.
 
void free_garbage (t_garbage *garbage)
 Free the garbage.
 
void print_garbage (t_garbage *garbage)
 Print the garbage collector.
 
t_elementft_garbagenew (void *ptr)
 Allocates and returns the newly created element 'value' is initialised with content 'next' is set to NULL.
 
void ft_garbageadd_front (t_garbage *garbage, t_element *new)
 Adds the 'new' element at the start of stack.
 
void ft_garbageadd_back (t_garbage *stack, t_element *new) __attribute__((deprecated))
 Adds the 'new' element at the end of stack.
 
int ft_garbageclear (t_garbage *data)
 Remove all elements from garbage.
 

Detailed Description

Functions to simulate a garbage.

Function Documentation

◆ add_to_garbage()

void add_to_garbage ( t_garbage * garbage,
void * ptr )

Add a pointer to the garbage list.

Parameters
garbagegarbage structure
ptrpointer to add
Here is the call graph for this function:

◆ free_element_gb()

void free_element_gb ( t_garbage * garbage,
void * ptr )

Free an element in the garbage collector.

Parameters
garbagegarbage structure
ptrelement to free

◆ free_garbage()

void free_garbage ( t_garbage * garbage)

Free the garbage.

Here is the call graph for this function:

◆ ft_garbageadd_back()

void ft_garbageadd_back ( t_garbage * garbage,
t_element * new )

Adds the 'new' element at the end of stack.

Deprecated
not used anywhere as add_front is faster
Parameters
garbagegarbage structure
newelement to add

◆ ft_garbageadd_front()

void ft_garbageadd_front ( t_garbage * garbage,
t_element * new )

Adds the 'new' element at the start of stack.

Parameters
garbagegarbage structure
newelement to add

◆ ft_garbageclear()

int ft_garbageclear ( t_garbage * garbage)

Remove all elements from garbage.

Parameters
garbagegarbage structure
Returns
int 0 OK, -1 is error

◆ ft_garbagenew()

t_element * ft_garbagenew ( void * ptr)

Allocates and returns the newly created element 'value' is initialised with content 'next' is set to NULL.

Parameters
ptrpointer 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
garbagegarbage structure
sourcestring to copy
Returns
char* pointer to the new string
Here is the call graph for this function:

◆ garbage_init()

void garbage_init ( t_garbage * garbage)

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
garbagegarbage structure
sizenumber of bytes to allocates
Returns
void*
Here is the call graph for this function:

◆ print_garbage()

void print_garbage ( t_garbage * garbage)

Print the garbage collector.