Sun, 26 Sep 2021 15:43:58 +0200
implement cx_tree_add_child_node using cx_linked_list_add
src/tree.c | file | annotate | diff | comparison | revisions |
--- a/src/tree.c Sun Sep 26 15:43:41 2021 +0200 +++ b/src/tree.c Sun Sep 26 15:43:58 2021 +0200 @@ -27,6 +27,7 @@ */ #include "cx/tree.h" +#include "cx/linked_list.h" #define CX_TR_PTR(cur, off) ((void**)(((char*)cur)+off)) @@ -66,5 +67,12 @@ void **children_end, void *new_node) { - return 1; + if(cx_linked_list_add(children_begin, children_end, loc_prev, loc_next, new_node)) { + return 1; + } + // optional field + if(loc_parent >= 0) { + *CX_TR_PTR(new_node, loc_parent) = parent; + } + return 0; }