aboutsummaryrefslogtreecommitdiff
path: root/vcal.c
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2019-02-04 00:36:57 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2019-02-04 00:36:57 +0100
commit2c2bdb8b66e386e14b5cc1a35abfbf242dcf2018 (patch)
tree7f640c7845bd26823b8d6108b4f554bf5b6c9d97 /vcal.c
parentAdd linked list generic type. (diff)
downloadcalp-2c2bdb8b66e386e14b5cc1a35abfbf242dcf2018.tar.gz
calp-2c2bdb8b66e386e14b5cc1a35abfbf242dcf2018.tar.xz
Work on propper memmory management for linked lists.
Diffstat (limited to 'vcal.c')
-rw-r--r--vcal.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/vcal.c b/vcal.c
index 0371a35b..73158aeb 100644
--- a/vcal.c
+++ b/vcal.c
@@ -26,6 +26,20 @@ int CONSTRUCTOR_DECL(vevent, char* filename) {
return 0;
}
+int RESOLVE(content_line)
+ (content_line** dest, content_line* new) {
+ if (*dest == NULL) *dest = new;
+
+ if (strbuf_cmp(&(*dest)->key, &new->key) != 0) {
+ ERR("Can't resolve between these two types");
+ return 1;
+ }
+
+ // printf("len = %i\n", dest->vals.length);
+ APPEND(LLIST(strbuf))(&(*dest)->vals, &new->vals);
+ return 0;
+}
+
content_line* get_property (vevent* ev, char* key) {
return TRIE_GET(content_line)(&ev->clines, key);
}
@@ -67,7 +81,8 @@ int content_line_copy (content_line* dest, content_line* src) {
int FREE_DECL(content_line) {
FREE(strbuf)(&this->key);
// FREE(strbuf)(&this->val);
- LLIST_FREE(strbuf)(&this->vals);
+ // LLIST_FREE(strbuf)(&this->vals);
+ FREE(LLIST(strbuf))(&this->vals);
for (int i = 0; i < cline_ptr; i++) {
if (clines[i] == this) {
clines[i] = NULL;