diff options
Diffstat (limited to 'src/core/garbage.c')
| -rw-r--r-- | src/core/garbage.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/core/garbage.c b/src/core/garbage.c index aba19c4..3820144 100644 --- a/src/core/garbage.c +++ b/src/core/garbage.c @@ -65,6 +65,12 @@ _garbage_print(_Garbage *p_garbage) { } void +_garbage_free(_Garbage *p_garbage) { + (*p_garbage->p_func) (p_garbage->p_2free); + free(p_garbage); +} + +void garbage_destroy() { garbage_collect(); @@ -87,17 +93,18 @@ garbage_destroy() { int garbage_collect() { + //printf("GARBAGE_COLLECT\n"); ListIterator *p_iter = listiterator_new(LIST_GARBAGE); List *p_list_garbage_new = list_new(); int i_count = 0; + //printf("size %d\n", list_size(LIST_GARBAGE)); while (listiterator_has_next(p_iter)) { _Garbage *p_garbage = listiterator_next(p_iter); if (p_garbage->p_ref_count == NULL || *p_garbage->p_ref_count <= 0) { - // _garbage_print(p_garbage); - (*p_garbage->p_func) (p_garbage->p_2free); - free(p_garbage); + //_garbage_print(p_garbage); + _garbage_free(p_garbage); ++i_count; } else { @@ -106,9 +113,9 @@ garbage_collect() { } listiterator_delete(p_iter); - list_delete(LIST_GARBAGE); LIST_GARBAGE = p_list_garbage_new; + //printf("GARBAGE_COLLECT_END\n"); return (i_count); } |
