Browse Source

only trigger the if action is not null during walk or destroy

1.0.0
Georg Hopp 12 years ago
parent
commit
265c8661a6
  1. 8
      src/hash/hash.c
  2. 4
      src/tree/destroy.c
  3. 4
      src/tree/walk.c
  4. 4
      trdata.h

8
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)

4
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);

4
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)) {

4
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 <stdarg.h> 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 <stdint.h> header file. */
#define HAVE_STDINT_H 1

Loading…
Cancel
Save