Introduction
Introduction Statistics Contact Development Disclaimer Help
use maps everywhere relevant - ics2txt - convert icalendar .ics file to plain t…
git clone git://bitreich.org/ics2txt git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws…
Log
Files
Refs
Tags
README
---
commit 775c76c450eed349600344550bbb6c140bdf1811
parent d4d55c6876bf51dd555a0dbfae0316343d44997e
Author: Josuah Demangeon <[email protected]>
Date: Sun, 28 Jun 2020 18:53:48 +0200
use maps everywhere relevant
Diffstat:
M src/ical.c | 22 +++++++++++++++-------
M src/ical.h | 2 +-
2 files changed, 16 insertions(+), 8 deletions(-)
---
diff --git a/src/ical.c b/src/ical.c
@@ -130,19 +130,25 @@ err:
}
static void
-ical_free_vnode_value(void *v)
+ical_free_value_void(void *v)
{
ical_free_value(v);
}
+static void
+ical_free_vnode_void(void *v)
+{
+ ical_free_vnode(v);
+}
+
void
ical_free_vnode(struct ical_vnode *node)
{
if (node == NULL)
return;
debug("free vnode %p %s", node, node->name);
- map_free(&node->values, ical_free_vnode_value);
- ical_free_vnode(node->child);
+ map_free(&node->values, ical_free_value_void);
+ map_free(&node->child, ical_free_vnode_void);
ical_free_vnode(node->next);
free(node);
}
@@ -190,12 +196,14 @@ ical_begin_vnode(struct ical_vcalendar *vcal, char const …
goto err;
if (vcal->root == NULL) {
vcal->root = new;
- vcal->current = new;
} else {
- new->next = vcal->current->child;
- vcal->current->child = new;
- vcal->current = new;
+ new->next = map_get(&vcal->current->child, new->name);
+ if (map_set(&vcal->current->child, new->name, new) < 0) {
+ e = -ICAL_ERR_SYSTEM;
+ goto err;
+ }
}
+ vcal->current = new;
return 0;
err:
ical_free_vnode(new);
diff --git a/src/ical.h b/src/ical.h
@@ -34,7 +34,7 @@ struct ical_vnode {
char name[32];
time_t beg, end;
struct map values; /*(struct ical_value *)*/
- struct ical_vnode *child;
+ struct map child; /*(struct ical_vnode *)*/
struct ical_vnode *next;
};
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.