| 211 * Releases internal memory of the given tree iterator. |
211 * Releases internal memory of the given tree iterator. |
| 212 * @param iter the iterator |
212 * @param iter the iterator |
| 213 */ |
213 */ |
| 214 cx_attr_nonnull |
214 cx_attr_nonnull |
| 215 static inline void cxTreeIteratorDispose(CxTreeIterator *iter) { |
215 static inline void cxTreeIteratorDispose(CxTreeIterator *iter) { |
| 216 free(iter->stack); |
216 cxFree(cxDefaultAllocator, iter->stack); |
| 217 iter->stack = NULL; |
217 iter->stack = NULL; |
| 218 } |
218 } |
| 219 |
219 |
| 220 /** |
220 /** |
| 221 * Releases internal memory of the given tree visitor. |
221 * Releases internal memory of the given tree visitor. |
| 441 |
441 |
| 442 /** |
442 /** |
| 443 * Creates a depth-first iterator for a tree with the specified root node. |
443 * Creates a depth-first iterator for a tree with the specified root node. |
| 444 * |
444 * |
| 445 * @note A tree iterator needs to maintain a stack of visited nodes, which is |
445 * @note A tree iterator needs to maintain a stack of visited nodes, which is |
| 446 * allocated using stdlib malloc(). |
446 * allocated using the cxDefaultAllocator. |
| 447 * When the iterator becomes invalid, this memory is automatically released. |
447 * When the iterator becomes invalid, this memory is automatically released. |
| 448 * However, if you wish to cancel the iteration before the iterator becomes |
448 * However, if you wish to cancel the iteration before the iterator becomes |
| 449 * invalid by itself, you MUST call cxTreeIteratorDispose() manually to release |
449 * invalid by itself, you MUST call cxTreeIteratorDispose() manually to release |
| 450 * the memory. |
450 * the memory. |
| 451 * |
451 * |
| 469 ); |
469 ); |
| 470 |
470 |
| 471 /** |
471 /** |
| 472 * Creates a breadth-first iterator for a tree with the specified root node. |
472 * Creates a breadth-first iterator for a tree with the specified root node. |
| 473 * |
473 * |
| 474 * @note A tree visitor needs to maintain a queue of to be visited nodes, which |
474 * @note A tree visitor needs to maintain a queue of to-be visited nodes, which |
| 475 * is allocated using stdlib malloc(). |
475 * is allocated using the cxDefaultAllocator. |
| 476 * When the visitor becomes invalid, this memory is automatically released. |
476 * When the visitor becomes invalid, this memory is automatically released. |
| 477 * However, if you wish to cancel the iteration before the visitor becomes |
477 * However, if you wish to cancel the iteration before the visitor becomes |
| 478 * invalid by itself, you MUST call cxTreeVisitorDispose() manually to release |
478 * invalid by itself, you MUST call cxTreeVisitorDispose() manually to release |
| 479 * the memory. |
479 * the memory. |
| 480 * |
480 * |
| 956 * |
956 * |
| 957 * @note This function will also register an advanced destructor which |
957 * @note This function will also register an advanced destructor which |
| 958 * will free the nodes with the allocator's free() method. |
958 * will free the nodes with the allocator's free() method. |
| 959 * |
959 * |
| 960 * @param allocator the allocator that shall be used |
960 * @param allocator the allocator that shall be used |
| 961 * (if @c NULL, a default stdlib allocator will be used) |
961 * (if @c NULL, the cxDefaultAllocator will be used) |
| 962 * @param create_func a function that creates new nodes |
962 * @param create_func a function that creates new nodes |
| 963 * @param search_func a function that compares two nodes |
963 * @param search_func a function that compares two nodes |
| 964 * @param search_data_func a function that compares a node with data |
964 * @param search_data_func a function that compares a node with data |
| 965 * @param loc_parent offset in the node struct for the parent pointer |
965 * @param loc_parent offset in the node struct for the parent pointer |
| 966 * @param loc_children offset in the node struct for the children linked list |
966 * @param loc_children offset in the node struct for the children linked list |
| 1020 * where neither the create function, the search function, nor a destructor |
1020 * where neither the create function, the search function, nor a destructor |
| 1021 * will be set. If you wish to use any of this functionality for the wrapped |
1021 * will be set. If you wish to use any of this functionality for the wrapped |
| 1022 * tree, you need to specify those functions afterwards. |
1022 * tree, you need to specify those functions afterwards. |
| 1023 * |
1023 * |
| 1024 * @param allocator the allocator that was used for nodes of the wrapped tree |
1024 * @param allocator the allocator that was used for nodes of the wrapped tree |
| 1025 * (if @c NULL, a default stdlib allocator is assumed) |
1025 * (if @c NULL, the cxDefaultAllocator is assumed) |
| 1026 * @param root the root node of the tree that shall be wrapped |
1026 * @param root the root node of the tree that shall be wrapped |
| 1027 * @param loc_parent offset in the node struct for the parent pointer |
1027 * @param loc_parent offset in the node struct for the parent pointer |
| 1028 * @param loc_children offset in the node struct for the children linked list |
1028 * @param loc_children offset in the node struct for the children linked list |
| 1029 * @param loc_last_child optional offset in the node struct for the pointer to |
1029 * @param loc_last_child optional offset in the node struct for the pointer to |
| 1030 * the last child in the linked list (negative if there is no such pointer) |
1030 * the last child in the linked list (negative if there is no such pointer) |