summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/tree.c10
-rw-r--r--zix/tree.h2
2 files changed, 7 insertions, 5 deletions
diff --git a/src/tree.c b/src/tree.c
index 74f882a..8523228 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -100,12 +100,14 @@ ZIX_API
void
zix_tree_free(ZixTree* t)
{
- zix_tree_free_rec(t, t->root);
- free(t);
+ if (t) {
+ zix_tree_free_rec(t, t->root);
+ free(t);
+ }
}
size_t
-zix_tree_size(ZixTree* t)
+zix_tree_size(const ZixTree* t)
{
return t->size;
}
@@ -618,7 +620,7 @@ ZIX_API
void*
zix_tree_get(ZixTreeIter* ti)
{
- return ti->data;
+ return ti ? ti->data : NULL;
}
ZIX_API
diff --git a/zix/tree.h b/zix/tree.h
index b54087c..87a6c25 100644
--- a/zix/tree.h
+++ b/zix/tree.h
@@ -64,7 +64,7 @@ zix_tree_free(ZixTree* t);
*/
ZIX_API
size_t
-zix_tree_size(ZixTree* t);
+zix_tree_size(const ZixTree* t);
/**
Insert the element @a e into @a t and point @a ti at the new element.