aboutsummaryrefslogtreecommitdiff
path: root/vcal.c
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2019-02-04 18:23:51 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2019-02-05 18:16:17 +0100
commit14b33ae9c00f74a24a00aaece88b22af0955379e (patch)
treecee997634ecb0977e8f63fadfd6d00fdfdf89439 /vcal.c
parentNormalize and improve INIT & FREE macros. (diff)
downloadcalp-14b33ae9c00f74a24a00aaece88b22af0955379e.tar.gz
calp-14b33ae9c00f74a24a00aaece88b22af0955379e.tar.xz
Fix most memmory errors.
Diffstat (limited to 'vcal.c')
-rw-r--r--vcal.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/vcal.c b/vcal.c
index 64cc1d73..a62c99a4 100644
--- a/vcal.c
+++ b/vcal.c
@@ -26,18 +26,26 @@ INIT_F(vevent, char* filename) {
return 0;
}
-int RESOLVE(content_line)
- (content_line** dest, content_line* new) {
- if (*dest == NULL) *dest = new;
+content_line* RESOLVE(content_line)
+ (content_line* dest, content_line* new) {
- if (strbuf_cmp(&(*dest)->key, &new->key) != 0) {
+ if (dest == NULL) return new;
+
+ if (strbuf_cmp(&dest->key, &new->key) != 0) {
ERR("Can't resolve between these two types");
- return 1;
+ return NULL;
}
- // printf("len = %i\n", dest->vals.length);
- APPEND(LLIST(strbuf))(&(*dest)->vals, &new->vals);
- return 0;
+ /* TODO actuall iterators could be fun */
+ for (LINK(strbuf)* s = new->vals.head->after;
+ s->after != NULL;
+ s = s->after) {
+ LLIST_CONS(strbuf) (&dest->vals, s->value);
+ }
+
+ FREE(content_line)(new);
+
+ return dest;
}
content_line* get_property (vevent* ev, char* key) {
@@ -83,6 +91,8 @@ FREE_F(content_line) {
// FREE(strbuf)(&this->val);
// LLIST_FREE(strbuf)(&this->vals);
FREE(LLIST(strbuf))(&this->vals);
+
+ // TODO this is just for the GC.
for (int i = 0; i < cline_ptr; i++) {
if (clines[i] == this) {
clines[i] = NULL;