From 783cb95713a2e97bda53d5f3c2112303d38d3507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Wed, 6 Feb 2019 11:41:37 +0100 Subject: Remove GC. --- main.c | 12 ------------ vcal.c | 28 ---------------------------- vcal.h | 13 ------------- 3 files changed, 53 deletions(-) diff --git a/main.c b/main.c index 87be26ff..6ed74323 100644 --- a/main.c +++ b/main.c @@ -61,16 +61,4 @@ int main (int argc, char* argv[argc]) { } } free_vcalendar(&cal); - - for (int i = 0; i < gc_ptr; i++) { - if (gc_vect[i] != NULL) { - // printf("clines[%i] : [%s] := [%s]\n", i, clines[i]->key.mem, clines[i]->val.mem); - // printf("gc_vect[%i] : [%s] := [%s]\n", i, gc_vect[i]->key.mem, gc_vect[i]->vals.head->after->value->mem); - printf("gc_vect[%i] : [%s] := [%s]\n", i, - ((content_line*) gc_vect[i])->key.mem, - ((content_line*) gc_vect[i])->vals.head->after->value->mem); - } - } - - free(gc_vect); } diff --git a/vcal.c b/vcal.c index 5ad35feb..a2a0bd90 100644 --- a/vcal.c +++ b/vcal.c @@ -42,7 +42,6 @@ content_line* RESOLVE(content_line) APPEND(LLIST(strbuf)) (&dest->vals, &new->vals); FREE(strbuf)(&new->key); - gc_free(new); free(new); return dest; @@ -53,8 +52,6 @@ content_line* get_property (vevent* ev, char* key) { } INIT_F(content_line) { - gc_register(this); - INIT(strbuf, &this->key); // INIT(strbuf, &this->val); INIT( LLIST(strbuf), &this->vals ); @@ -63,7 +60,6 @@ INIT_F(content_line) { } INIT_F(content_line, int keylen, int vallen) { - gc_register(this); INIT(strbuf, &this->key, keylen); // INIT(strbuf, &this->val, vallen); INIT( LLIST(strbuf), &this->vals ); @@ -89,8 +85,6 @@ FREE_F(content_line) { // LLIST_FREE(strbuf)(&this->vals); FREE(LLIST(strbuf))(&this->vals); - gc_free(this); - // TODO remaining fields return 0; } @@ -126,10 +120,6 @@ int push_event(vcalendar* cal, vevent* ev) { } INIT_F(vcalendar) { - // TODO remove - gc_vect = calloc(sizeof(*gc_vect), 10000); - gc_ptr = 0; - this->alloc = 1; this->events = calloc(sizeof(*this->events), this->alloc); this->n_events = 0; @@ -143,21 +133,3 @@ int free_vcalendar (vcalendar* cal) { free (cal->events); return 0; } - -void** gc_vect; -int gc_ptr; - -int gc_register(void* ptr) { - gc_vect[gc_ptr++] = ptr; - return 0; -} - -int gc_free(void* ptr) { - for (int i = 0; i < gc_ptr; i++) { - if (gc_vect[i] == ptr) { - gc_vect[i] = NULL; - } - } - - return 0; -} diff --git a/vcal.h b/vcal.h index d25a77aa..946b626c 100644 --- a/vcal.h +++ b/vcal.h @@ -73,17 +73,4 @@ int free_vcalendar (vcalendar* cal); */ int push_event(vcalendar* cal, vevent* ev); -/* - * NOTE - * these create a very basic garbage collector. It shouldn't be used, - * but is useful for finding lost memmory during debugging. - * TODO - * remove it. - */ -extern void** gc_vect; -extern int gc_ptr; - -int gc_register(void* ptr); -int gc_free(void* ptr); - #endif /* VCAL_H */ -- cgit v1.2.3