-
Notifications
You must be signed in to change notification settings - Fork 0
/
gc_free.c
35 lines (31 loc) · 1.37 KB
/
gc_free.c
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
/* ************************************************************************** */
/* LE - / */
/* / */
/* gc_free.c .:: .:/ . .:: */
/* +:+:+ +: +: +:+:+ */
/* By: aviscogl <[email protected]> +:+ +: +: +:+ */
/* #+# #+ #+ #+# */
/* Created: 2018/01/10 13:28:22 by aviscogl #+# ## ## #+# */
/* Updated: 2018/01/10 13:38:28 by aviscogl ### #+. /#+ ###.fr */
/* / */
/* / */
/* ************************************************************************** */
#include "gc.h"
void gc_free(void *ptr)
{
t_gc_list *lst;
lst = g_gc.pointer_map[HASH(ptr) % P_MAP_SIZE];
if (lst && gc_list_exist(lst, (uintptr_t)lst))
{
gc_list_rm(&lst, (uintptr_t)lst);
gc_mfree(lst);
}
}
void gc_mfree(t_gc_list *e)
{
DEBUGP("Free %p with size %zu allocated in %s:%d\n",
(void *)e->data.start, e->data.size, e->data.file,
e->data.line);
free((void *)e->data.start);
g_gc.pointer_nb--;
}