-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgc_free.c
More file actions
39 lines (36 loc) · 1.23 KB
/
gc_free.c
File metadata and controls
39 lines (36 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* gc_free.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ayelasef <ayelasef@1337.ma> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/07/10 13:06:44 by ayelasef #+# #+# */
/* Updated: 2025/07/10 13:06:58 by ayelasef ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void gc_free(t_gc *gc, void *ptr)
{
t_gc_node *curr;
t_gc_node *prev;
if (!gc || !ptr)
return ;
curr = gc->list;
prev = NULL;
while (curr)
{
if (curr->ptr == ptr)
{
if (prev)
prev->next = curr->next;
else
gc->list = curr->next;
free(curr->ptr);
free(curr);
return ;
}
prev = curr;
curr = curr->next;
}
}