Introduction
Introduction Statistics Contact Development Disclaimer Help
fix remaining memory leaks, 4 still reachable due to libc - ics2txt - convert i…
git clone git://bitreich.org/ics2txt git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws…
Log
Files
Refs
Tags
README
---
commit 9c990aa7ff527f1b12ce915e7d8d4148d6fb0438
parent 5364436bda9ac04c42dbd6eeaab75914128046b6
Author: Josuah Demangeon <[email protected]>
Date: Mon, 29 Jun 2020 00:06:33 +0200
fix remaining memory leaks, 4 still reachable due to libc
Diffstat:
M ics2tree.c | 12 +++++-------
M src/ical.c | 12 ++++--------
M src/ical.h | 3 +--
3 files changed, 10 insertions(+), 17 deletions(-)
---
diff --git a/ics2tree.c b/ics2tree.c
@@ -40,12 +40,11 @@ print_ical_tree_vnode(struct ical_vnode *node, int level)
if (node == NULL)
return;
print_ruler(level);
- fprintf(stdout, "node %p %s child=%lu next=%p\n",
- (void *)node, node->name, node->child.len, (void *)node->next);
+ fprintf(stdout, "node %s\n", node->name);
for (size_t i = 0; i < node->values.len; i++)
print_ical_tree_value(node->values.entry[i].value, level + 1);
- for (size_t i = 0; i < node->child.len; i++)
- print_ical_tree_vnode(node->child.entry[i].value, level + 1);
+ for (size_t i = 0; i < node->childs.len; i++)
+ print_ical_tree_vnode(node->childs.entry[i].value, level + 1);
print_ical_tree_vnode(node->next, level);
}
@@ -59,7 +58,7 @@ print_ical_tree(FILE *fp)
die("reading ical file: %s", ical_strerror(e));
print_ical_tree_vnode(vcal.root, 0);
- fprintf(stdout, ": end\n");
+ fprintf(stdout, "end\n");
fflush(stdout);
ical_free_vcalendar(&vcal);
@@ -79,13 +78,12 @@ main(int argc, char **argv)
for (; *argv != NULL; argv++, argc--) {
FILE *fp;
- info("converting \"%s\"", *argv);
+ debug("converting \"%s\"", *argv);
if ((fp = fopen(*argv, "r")) == NULL)
die("opening %s", *argv);
if (print_ical_tree(fp) < 0)
die("converting %s", *argv);
fclose(fp);
}
-
return 0;
}
diff --git a/src/ical.c b/src/ical.c
@@ -86,8 +86,7 @@ ical_new_value(char const *line)
void
ical_free_value(struct ical_value *value)
{
- debug("free value %p (%s:%s)", value, value->name, value->value);
- map_free(&value->param, free);
+ map_free(&value->param, NULL);
free(value);
}
@@ -154,9 +153,8 @@ 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_value_void);
- map_free(&node->child, ical_free_vnode_void);
+ map_free(&node->childs, ical_free_vnode_void);
ical_free_vnode(node->next);
free(node);
}
@@ -205,8 +203,8 @@ ical_begin_vnode(struct ical_vcalendar *vcal, char const *n…
if (vcal->root == NULL) {
vcal->root = new;
} else {
- new->next = map_get(&vcal->current->child, new->name);
- if (map_set(&vcal->current->child, new->name, new) < 0) {
+ new->next = map_get(&vcal->current->childs, new->name);
+ if (map_set(&vcal->current->childs, new->name, new) < 0) {
e = -ICAL_ERR_SYSTEM;
goto err;
}
@@ -247,7 +245,6 @@ ical_push_value(struct ical_vcalendar *vcal, struct ical_va…
if (vcal->current == NULL)
return -ICAL_ERR_MISSING_BEGIN;
- debug("new %p %s:%s", new, new->name, new->value);
new->next = map_get(&vcal->current->values, new->name);
if (map_set(&vcal->current->values, new->name, new) < 0)
return -ICAL_ERR_SYSTEM;
@@ -287,6 +284,5 @@ err:
void
ical_free_vcalendar(struct ical_vcalendar *vcal)
{
- debug("free vcalendar");
ical_free_vnode(vcal->root);
}
diff --git a/src/ical.h b/src/ical.h
@@ -35,9 +35,8 @@ struct ical_vcalendar {
struct ical_vnode {
char name[32];
- time_t beg, end;
struct map values; /*(struct ical_value *)*/
- struct map child; /*(struct ical_vnode *)*/
+ struct map childs; /*(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.