| 456 ptrdiff_t loc_children, |
456 ptrdiff_t loc_children, |
| 457 ptrdiff_t loc_next |
457 ptrdiff_t loc_next |
| 458 ) { |
458 ) { |
| 459 CxTreeIterator ret; |
459 CxTreeIterator ret; |
| 460 ret.visit_on_exit = false; |
460 ret.visit_on_exit = false; |
| |
461 ret.exiting = false; |
| 461 ret.use_dfs = false; |
462 ret.use_dfs = false; |
| 462 ret.loc_children = loc_children; |
463 ret.loc_children = loc_children; |
| 463 ret.loc_next = loc_next; |
464 ret.loc_next = loc_next; |
| 464 |
465 |
| 465 // initialize members |
466 // initialize members |
| 566 cx_tree_add(parent, child, tree_layout(tree)); |
567 cx_tree_add(parent, child, tree_layout(tree)); |
| 567 tree->collection.size++; |
568 tree->collection.size++; |
| 568 } |
569 } |
| 569 |
570 |
| 570 void *cxTreeAddData(CxTree *tree, void *parent, const void *data) { |
571 void *cxTreeAddData(CxTree *tree, void *parent, const void *data) { |
| |
572 if (tree->loc_data < 0) return NULL; |
| |
573 |
| 571 void *node = cxZalloc(tree->collection.allocator, tree->node_size); |
574 void *node = cxZalloc(tree->collection.allocator, tree->node_size); |
| 572 if (node == NULL) return NULL; // LCOV_EXCL_LINE |
575 if (node == NULL) return NULL; // LCOV_EXCL_LINE |
| 573 |
576 |
| 574 char *dst = node; |
577 char *dst = node; |
| 575 dst += tree->loc_data; |
578 dst += tree->loc_data; |
| 747 node, true, |
750 node, true, |
| 748 tree->loc_children, tree->loc_next |
751 tree->loc_children, tree->loc_next |
| 749 ); |
752 ); |
| 750 cx_foreach(void *, child, iter) { |
753 cx_foreach(void *, child, iter) { |
| 751 if (iter.exiting) { |
754 if (iter.exiting) { |
| 752 cx_invoke_destructor(tree, child); |
755 // always call the destructors with the node! |
| |
756 cx_invoke_destructor_raw(tree, child); |
| 753 } |
757 } |
| 754 } |
758 } |
| 755 tree->collection.size -= iter.counter; |
759 tree->collection.size -= iter.counter; |
| 756 if (node == tree->root) { |
760 if (node == tree->root) { |
| 757 tree->root = NULL; |
761 tree->root = NULL; |