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 |
1.1 --- a/src/tree.c Sun Sep 26 15:43:41 2021 +0200 1.2 +++ b/src/tree.c Sun Sep 26 15:43:58 2021 +0200 1.3 @@ -27,6 +27,7 @@ 1.4 */ 1.5 1.6 #include "cx/tree.h" 1.7 +#include "cx/linked_list.h" 1.8 1.9 #define CX_TR_PTR(cur, off) ((void**)(((char*)cur)+off)) 1.10 1.11 @@ -66,5 +67,12 @@ 1.12 void **children_end, 1.13 void *new_node) 1.14 { 1.15 - return 1; 1.16 + if(cx_linked_list_add(children_begin, children_end, loc_prev, loc_next, new_node)) { 1.17 + return 1; 1.18 + } 1.19 + // optional field 1.20 + if(loc_parent >= 0) { 1.21 + *CX_TR_PTR(new_node, loc_parent) = parent; 1.22 + } 1.23 + return 0; 1.24 }