From 265c8661a625a0ca126e5e1ae65cb82a3d032dac Mon Sep 17 00:00:00 2001 From: Georg Hopp Date: Mon, 7 Jul 2014 07:53:21 +0100 Subject: [PATCH] only trigger the if action is not null during walk or destroy --- src/hash/hash.c | 8 -------- src/tree/destroy.c | 4 +++- src/tree/walk.c | 4 +++- trdata.h | 4 ++-- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/hash/hash.c b/src/hash/hash.c index 0684951..3e499c3 100644 --- a/src/hash/hash.c +++ b/src/hash/hash.c @@ -34,14 +34,6 @@ hashCtor(void * _this, va_list * params) return 0; } -static -inline -void -tDelete(const void * node, const int depth) -{ - TR_delete(node); -} - static void hashDtor(void * _this) diff --git a/src/tree/destroy.c b/src/tree/destroy.c index 2aa92d9..42cc1a2 100644 --- a/src/tree/destroy.c +++ b/src/tree/destroy.c @@ -46,7 +46,9 @@ TR_treeDestroy(TR_Tree * this, TR_TreeAction action) TR_Tree parent = TR_TREE_PARENT(node); - action(node->data, depth); + if (action) { + action(node->data, depth); + } previous = node; TR_delete(node); diff --git a/src/tree/walk.c b/src/tree/walk.c index ceae6ce..c96ddd5 100644 --- a/src/tree/walk.c +++ b/src/tree/walk.c @@ -38,7 +38,9 @@ TR_treeWalk(TR_Tree this, TR_TreeAction action) } if (NULL == TR_TREE_LEFT(node) || previous == TR_TREE_LEFT(node)) { - action(node->data, depth); + if (action) { + action(node->data, depth); + } previous = node; if (NULL != TR_TREE_RIGHT(node)) { diff --git a/trdata.h b/trdata.h index ae6b4fd..d8978cf 100644 --- a/trdata.h +++ b/trdata.h @@ -11,13 +11,13 @@ #define HAVE_MEMORY_H 1 /* Define to 1 if you have the `memset' function. */ -#define HAVE_MEMSET 1 +/* #undef HAVE_MEMSET */ /* Define to 1 if you have the header file. */ #define HAVE_STDARG_H 1 /* Define to 1 if stdbool.h conforms to C99. */ -#define HAVE_STDBOOL_H 1 +/* #undef HAVE_STDBOOL_H */ /* Define to 1 if you have the header file. */ #define HAVE_STDINT_H 1