# HG changeset patch # User Mike Becker # Date 1732655787 -3600 # Node ID b642eca4b95678dd94c528b5492b3451fc43a3cb # Parent 14ca894190fdc4eb93e64c9890f1d6fbd805f5d7 make names of destroy and free functions consistent - fixes #484 diff -r 14ca894190fd -r b642eca4b956 CHANGELOG --- a/CHANGELOG Tue Nov 26 22:00:03 2024 +0100 +++ b/CHANGELOG Tue Nov 26 22:16:27 2024 +0100 @@ -14,6 +14,7 @@ * adds cx_nmemb() utility function to common.h * changes all functions, for which there is no dedicated xyz_a variant, to accept NULL as allocator argument (in which case a default allocator will be used) + * changes the name of destroy functions that actually free the memory to better indicate their behavior * moves cx_compare_func typedef to compare.h * moves cx_szmul() to common.h * moves stream copy functions to new streams.h diff -r 14ca894190fd -r b642eca4b956 docs/src/features.md --- a/docs/src/features.md Tue Nov 26 22:00:03 2024 +0100 +++ b/docs/src/features.md Tue Nov 26 22:16:27 2024 +0100 @@ -90,12 +90,12 @@ It also allows you to register destructor functions for the allocated memory, which are automatically called before the memory is deallocated. Additionally, you may also register _independent_ destructor functions within a pool in case some external library -allocated memory for you, which should be destroyed together with this pool. +allocated memory for you, which should be freed together with this pool. Many UCX features support the use of an allocator. The [strings](#string), for instance, provide several functions suffixed with `_a` that allow specifying an allocator. You can use this to keep track of the memory occupied by dynamically allocated strings and cleanup everything with -just a single call to `cxMempoolDestroy()`. +just a single call to `cxMempoolFree()`. The following code illustrates this on the example of reading a CSV file into memory. ```C @@ -145,7 +145,7 @@ size_t fc = cx_strsplit(lines[i], CX_STR(";"), 3, fields); if (fc != 3) { fprintf(stderr, "Syntax error in line %zu.\n", i); - cxMempoolDestroy(pool); + cxMempoolFree(pool); return 1; } CSVData data; @@ -168,7 +168,7 @@ } // cleanup everything, no manual free() needed - cxMempoolDestroy(pool); + cxMempoolFree(pool); return 0; } diff -r 14ca894190fd -r b642eca4b956 src/cx/array_list.h --- a/src/cx/array_list.h Tue Nov 26 22:00:03 2024 +0100 +++ b/src/cx/array_list.h Tue Nov 26 22:16:27 2024 +0100 @@ -430,7 +430,7 @@ */ cx_attr_nodiscard cx_attr_malloc -cx_attr_dealloc(cxListDestroy, 1) +cx_attr_dealloc(cxListFree, 1) CxList *cxArrayListCreate( const CxAllocator *allocator, cx_compare_func comparator, diff -r 14ca894190fd -r b642eca4b956 src/cx/hash_map.h --- a/src/cx/hash_map.h Tue Nov 26 22:00:03 2024 +0100 +++ b/src/cx/hash_map.h Tue Nov 26 22:16:27 2024 +0100 @@ -84,7 +84,7 @@ */ cx_attr_nodiscard cx_attr_malloc -cx_attr_dealloc(cxMapDestroy, 1) +cx_attr_dealloc(cxMapFree, 1) CxMap *cxHashMapCreate( const CxAllocator *allocator, size_t itemsize, diff -r 14ca894190fd -r b642eca4b956 src/cx/linked_list.h --- a/src/cx/linked_list.h Tue Nov 26 22:00:03 2024 +0100 +++ b/src/cx/linked_list.h Tue Nov 26 22:16:27 2024 +0100 @@ -66,7 +66,7 @@ */ cx_attr_nodiscard cx_attr_malloc -cx_attr_dealloc(cxListDestroy, 1) +cx_attr_dealloc(cxListFree, 1) CxList *cxLinkedListCreate( const CxAllocator *allocator, cx_compare_func comparator, diff -r 14ca894190fd -r b642eca4b956 src/cx/list.h --- a/src/cx/list.h Tue Nov 26 22:00:03 2024 +0100 +++ b/src/cx/list.h Tue Nov 26 22:16:27 2024 +0100 @@ -74,10 +74,10 @@ * Destructor function. * * Implementations SHALL invoke the content destructor functions if provided - * and SHALL deallocate the list memory. + * and SHALL deallocate the entire list memory. */ cx_attr_nonnull - void (*destructor)(struct cx_list_s *list); + void (*deallocate)(struct cx_list_s *list); /** * Member function for inserting a single element. @@ -882,16 +882,13 @@ /** * Deallocates the memory of the specified list structure. * - * Also calls content a destructor function, depending on the configuration - * in CxList.content_destructor_type. - * - * This function itself is a destructor function for the CxList. + * Also calls the content destructor function for each element, if specified. * - * @param list the list which shall be destroyed + * @param list the list which shall be freed */ -static inline void cxListDestroy(CxList *list) { +static inline void cxListFree(CxList *list) { if (list == NULL) return; - list->cl->destructor(list); + list->cl->deallocate(list); } /** diff -r 14ca894190fd -r b642eca4b956 src/cx/map.h --- a/src/cx/map.h Tue Nov 26 22:00:03 2024 +0100 +++ b/src/cx/map.h Tue Nov 26 22:16:27 2024 +0100 @@ -90,7 +90,7 @@ * Deallocates the entire memory. */ cx_attr_nonnull - void (*destructor)(struct cx_map_s *map); + void (*deallocate)(struct cx_map_s *map); /** * Removes all elements. @@ -204,11 +204,11 @@ /** * Deallocates the memory of the specified map. * - * @param map the map to be destroyed + * @param map the map to be freed */ -static inline void cxMapDestroy(CxMap *map) { +static inline void cxMapFree(CxMap *map) { if (map == NULL) return; - map->cl->destructor(map); + map->cl->deallocate(map); } diff -r 14ca894190fd -r b642eca4b956 src/cx/mempool.h --- a/src/cx/mempool.h Tue Nov 26 22:00:03 2024 +0100 +++ b/src/cx/mempool.h Tue Nov 26 22:16:27 2024 +0100 @@ -76,11 +76,11 @@ typedef struct cx_mempool_s CxMempool; /** - * Destroys a memory pool and frees the managed memory. + * Deallocates a memory pool and frees the managed memory. * - * @param pool the memory pool to destroy + * @param pool the memory pool to free */ -void cxMempoolDestroy(CxMempool *pool); +void cxMempoolFree(CxMempool *pool); /** * Creates an array-based memory pool with a shared destructor function. @@ -93,7 +93,7 @@ */ cx_attr_nodiscard cx_attr_malloc -cx_attr_dealloc(cxMempoolDestroy, 1) +cx_attr_dealloc(cxMempoolFree, 1) CxMempool *cxMempoolCreate(size_t capacity, cx_destructor_func destr); /** diff -r 14ca894190fd -r b642eca4b956 src/cx/test.h --- a/src/cx/test.h Tue Nov 26 22:00:03 2024 +0100 +++ b/src/cx/test.h Tue Nov 26 22:16:27 2024 +0100 @@ -155,8 +155,9 @@ } /** - * Destroys a test suite. - * @param suite the test suite to destroy + * Deallocates a test suite. + * + * @param suite the test suite to free */ static inline void cx_test_suite_free(CxTestSuite* suite) { if (suite == NULL) return; diff -r 14ca894190fd -r b642eca4b956 src/cx/tree.h --- a/src/cx/tree.h Tue Nov 26 22:00:03 2024 +0100 +++ b/src/cx/tree.h Tue Nov 26 22:16:27 2024 +0100 @@ -883,7 +883,7 @@ * the advanced destructor, starting with the leaf nodes of the subtree. * * When this function is invoked on the root node of the tree, it destroys the - * tree contents, but - in contrast to #cxTreeDestroy() - not the tree + * tree contents, but - in contrast to #cxTreeFree() - not the tree * structure, leaving an empty tree behind. * * \note The destructor function, if any, will \em not be invoked. That means @@ -895,7 +895,7 @@ * * @param tree the tree * @param node the node to remove - * @see cxTreeDestroy() + * @see cxTreeFree() */ cx_attr_nonnull void cxTreeDestroySubtree(CxTree *tree, void *node); @@ -921,7 +921,7 @@ #define cxTreeClear(tree) cxTreeDestroySubtree(tree, tree->root) /** - * Destroys the tree structure. + * Deallocates the tree structure. * * The destructor functions are invoked for each node, starting with the leaf * nodes. @@ -934,9 +934,9 @@ * that would cause a double-free in most scenarios where the advanced * destructor is already freeing the memory. * - * @param tree the tree to destroy + * @param tree the tree to free */ -static inline void cxTreeDestroy(CxTree *tree) { +static inline void cxTreeFree(CxTree *tree) { if (tree == NULL) return; if (tree->root != NULL) { cxTreeClear(tree); @@ -971,7 +971,7 @@ cx_attr_nonnull_arg(2, 3, 4) cx_attr_nodiscard cx_attr_malloc -cx_attr_dealloc(cxTreeDestroy, 1) +cx_attr_dealloc(cxTreeFree, 1) CxTree *cxTreeCreate( const CxAllocator *allocator, cx_tree_node_create_func create_func, @@ -1031,7 +1031,7 @@ cx_attr_nonnull_arg(2) cx_attr_nodiscard cx_attr_malloc -cx_attr_dealloc(cxTreeDestroy, 1) +cx_attr_dealloc(cxTreeFree, 1) CxTree *cxTreeCreateWrapped( const CxAllocator *allocator, void *root, diff -r 14ca894190fd -r b642eca4b956 src/list.c --- a/src/list.c Tue Nov 26 22:00:03 2024 +0100 +++ b/src/list.c Tue Nov 26 22:16:27 2024 +0100 @@ -59,7 +59,7 @@ } static void cx_pl_destructor(struct cx_list_s *list) { - list->climpl->destructor(list); + list->climpl->deallocate(list); } static int cx_pl_insert_element( diff -r 14ca894190fd -r b642eca4b956 src/mempool.c --- a/src/mempool.c Tue Nov 26 22:00:03 2024 +0100 +++ b/src/mempool.c Tue Nov 26 22:16:27 2024 +0100 @@ -137,7 +137,7 @@ abort(); } -void cxMempoolDestroy(CxMempool *pool) { +void cxMempoolFree(CxMempool *pool) { if (pool == NULL) return; struct cx_mempool_memory_s *mem; for (size_t i = 0; i < pool->size; i++) { diff -r 14ca894190fd -r b642eca4b956 tests/test_hash_map.c --- a/tests/test_hash_map.c Tue Nov 26 22:00:03 2024 +0100 +++ b/tests/test_hash_map.c Tue Nov 26 22:16:27 2024 +0100 @@ -56,7 +56,7 @@ cxMapStoreObjects(map); CX_TEST_ASSERT(!map->collection.store_pointer); - cxMapDestroy(map); + cxMapFree(map); CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); } cx_testing_allocator_destroy(&talloc); @@ -78,7 +78,7 @@ CX_TEST_ASSERT(map->collection.store_pointer); CX_TEST_ASSERT(map->collection.elem_size == sizeof(void *)); - cxMapDestroy(map); + cxMapFree(map); CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); } cx_testing_allocator_destroy(&talloc); @@ -119,7 +119,7 @@ CX_TEST_ASSERT(0 == strcmp(cxMapGet(map, "key 9"), "val 9")); CX_TEST_ASSERT(0 == strcmp(cxMapGet(map, "key 10"), "val 10")); - cxMapDestroy(map); + cxMapFree(map); CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); } cx_testing_allocator_destroy(&talloc); @@ -144,7 +144,7 @@ CX_TEST_ASSERT(result == 0); CX_TEST_ASSERT(((struct cx_hash_map_s *)map)->bucket_count == 8); - cxMapDestroy(map); + cxMapFree(map); CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); } cx_testing_allocator_destroy(&talloc); @@ -170,7 +170,7 @@ CX_TEST_ASSERT(cxMapGet(map, "key 2") == NULL); CX_TEST_ASSERT(cxMapGet(map, "key 3") == NULL); - cxMapDestroy(map); + cxMapFree(map); CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); } cx_testing_allocator_destroy(&talloc); @@ -220,7 +220,7 @@ } CX_TEST_ASSERT(s3found && s4found && s5found); - cxMapDestroy(map); + cxMapFree(map); CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); } cx_testing_allocator_destroy(&talloc); @@ -254,7 +254,7 @@ CX_TEST_ASSERT(cxMapGet(map, "key 5") == NULL); CX_TEST_ASSERT(cxMapGet(map, "key 6") != NULL); - cxMapDestroy(map); + cxMapFree(map); CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); } cx_testing_allocator_destroy(&talloc); @@ -333,7 +333,7 @@ v1[0] = v2[0] = v4[0] = v5[0] = 'c'; - cxMapDestroy(map); + cxMapFree(map); CX_TEST_ASSERT(0 == strcmp(v1, "cK")); CX_TEST_ASSERT(0 == strcmp(v2, "cK")); @@ -409,7 +409,7 @@ // assertion not possible // test that no segfault happens and valgrind is happy cxMapClear(cxEmptyMap); - cxMapDestroy(cxEmptyMap); + cxMapFree(cxEmptyMap); CX_TEST_ASSERT(true); } } @@ -453,7 +453,7 @@ CX_TEST_ASSERT(map->collection.size == 0); - cxMapDestroy(map); + cxMapFree(map); CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); } cx_testing_allocator_destroy(&talloc); @@ -649,7 +649,7 @@ } // destroy the map and verify the memory (de)allocations - cxMapDestroy(map); + cxMapFree(map); CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); } cx_testing_allocator_destroy(&talloc); diff -r 14ca894190fd -r b642eca4b956 tests/test_list.c --- a/tests/test_list.c Tue Nov 26 22:00:03 2024 +0100 +++ b/tests/test_list.c Tue Nov 26 22:16:27 2024 +0100 @@ -840,7 +840,7 @@ CxList copy = *cxEmptyList; cxListSort(cxEmptyList); cxListClear(cxEmptyList); - cxListDestroy(cxEmptyList); + cxListFree(cxEmptyList); CX_TEST_ASSERT(0 == memcmp(©, cxEmptyList, sizeof(CxList))); // NOLINT(*-suspicious-memory-comparison) } } @@ -880,8 +880,8 @@ CX_TEST_ASSERT(0 > cxListCompare(cxEmptyList, ll)); CX_TEST_ASSERT(0 > cxListCompare(cxEmptyList, al)); } - cxListDestroy(ll); - cxListDestroy(al); + cxListFree(ll); + cxListFree(al); } CX_TEST(test_list_ll_create) { @@ -899,7 +899,7 @@ CX_TEST_ASSERT(list->collection.allocator == alloc); CX_TEST_ASSERT(list->collection.cmpfunc == cx_cmp_int); CX_TEST_ASSERT(!cxListIsStoringPointers(list)); - cxListDestroy(list); + cxListFree(list); CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); } cx_testing_allocator_destroy(&talloc); @@ -918,7 +918,7 @@ CX_TEST_ASSERT(list->collection.cmpfunc == NULL); CX_TEST_ASSERT(!cxListIsStoringPointers(list)); } - cxListDestroy(list); + cxListFree(list); } CX_TEST(test_list_ll_store_pointers) { @@ -935,7 +935,7 @@ CX_TEST_ASSERT(list->climpl == NULL); CX_TEST_ASSERT(!cxListIsStoringPointers(list)); } - cxListDestroy(list); + cxListFree(list); } CX_TEST(test_list_ll_create_simple_for_pointers) { @@ -951,7 +951,7 @@ CX_TEST_ASSERT(list->collection.cmpfunc == cx_cmp_ptr); CX_TEST_ASSERT(cxListIsStoringPointers(list)); } - cxListDestroy(list); + cxListFree(list); } CX_TEST(test_list_arl_create) { @@ -969,7 +969,7 @@ CX_TEST_ASSERT(list->collection.allocator == alloc); CX_TEST_ASSERT(list->collection.cmpfunc == cx_cmp_int); CX_TEST_ASSERT(!cxListIsStoringPointers(list)); - cxListDestroy(list); + cxListFree(list); CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); } cx_testing_allocator_destroy(&talloc); @@ -988,7 +988,7 @@ CX_TEST_ASSERT(list->collection.cmpfunc == NULL); CX_TEST_ASSERT(!cxListIsStoringPointers(list)); } - cxListDestroy(list); + cxListFree(list); } CX_TEST(test_list_arl_create_simple_for_pointers) { @@ -1004,7 +1004,7 @@ CX_TEST_ASSERT(list->collection.cmpfunc == cx_cmp_ptr); CX_TEST_ASSERT(cxListIsStoringPointers(list)); } - cxListDestroy(list); + cxListFree(list); } static void test_fake_simple_int_destr(void *elem) { @@ -1020,7 +1020,7 @@ CxList *list = cxLinkedListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS); cxListAdd(list, item); CX_TEST_ASSERT(!cx_testing_allocator_verify(&talloc)); - cxListDestroy(list); + cxListFree(list); // item is not yet freed CX_TEST_ASSERT(!cx_testing_allocator_verify(&talloc)); cxFree(alloc, item); @@ -1035,7 +1035,7 @@ CxList *list = cxLinkedListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS); list->collection.simple_destructor = test_fake_simple_int_destr; cxListAdd(list, &item); - cxListDestroy(list); + cxListFree(list); CX_TEST_ASSERT(item == 42); } } @@ -1051,7 +1051,7 @@ list->collection.advanced_destructor = (cx_destructor_func2) cxFree; cxListAdd(list, item); CX_TEST_ASSERT(!cx_testing_allocator_verify(&talloc)); - cxListDestroy(list); + cxListFree(list); CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); } cx_testing_allocator_destroy(&talloc); @@ -1066,7 +1066,7 @@ CxList *list = cxArrayListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS, 4); cxListAdd(list, item); CX_TEST_ASSERT(!cx_testing_allocator_verify(&talloc)); - cxListDestroy(list); + cxListFree(list); // item is not yet freed CX_TEST_ASSERT(!cx_testing_allocator_verify(&talloc)); cxFree(alloc, item); @@ -1081,7 +1081,7 @@ CxList *list = cxArrayListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS, 4); list->collection.simple_destructor = test_fake_simple_int_destr; cxListAdd(list, &item); - cxListDestroy(list); + cxListFree(list); CX_TEST_ASSERT(item == 42); } } @@ -1097,7 +1097,7 @@ list->collection.advanced_destructor = (cx_destructor_func2) cxFree; cxListAdd(list, item); CX_TEST_ASSERT(!cx_testing_allocator_verify(&talloc)); - cxListDestroy(list); + cxListFree(list); CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); } cx_testing_allocator_destroy(&talloc); @@ -1109,7 +1109,7 @@ CxAllocator *alloc = &talloc.base; \ CX_TEST_DO { #define tear_down_combo \ - cxListDestroy(list); \ + cxListFree(list); \ CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc));\ } \ cx_testing_allocator_destroy(&talloc); @@ -1701,7 +1701,7 @@ CxList *other = otherctr; \ for (size_t i = 0; i < len; i++) cxListAdd(other, &testdata[i]); \ CX_TEST_CALL_SUBROUTINE(test_list_verify_compare, list, other); \ - cxListDestroy(other); \ + cxListFree(other); \ free(testdata); \ }) @@ -1728,7 +1728,7 @@ do_set_default_class_funcs(other); for (size_t i = 0; i < len; i++) cxListAdd(other, &testdata[i]); CX_TEST_CALL_SUBROUTINE(test_list_verify_compare, list, other); - cxListDestroy(other); + cxListFree(other); free(testdata); }) diff -r 14ca894190fd -r b642eca4b956 tests/test_mempool.c --- a/tests/test_mempool.c Tue Nov 26 22:00:03 2024 +0100 +++ b/tests/test_mempool.c Tue Nov 26 22:16:27 2024 +0100 @@ -46,7 +46,7 @@ CX_TEST_ASSERT(pool->size == 0); CX_TEST_ASSERT(pool->data != NULL); } - cxMempoolDestroy(pool); + cxMempoolFree(pool); } CX_TEST(test_mempool_malloc) { @@ -65,7 +65,7 @@ CX_TEST_ASSERT(pool->size == 6); CX_TEST_ASSERT(pool->capacity >= 6); } - cxMempoolDestroy(pool); + cxMempoolFree(pool); } CX_TEST(test_mempool_calloc) { @@ -76,7 +76,7 @@ CX_TEST_ASSERT(test[0] == 0); CX_TEST_ASSERT(test[1] == 0); } - cxMempoolDestroy(pool); + cxMempoolFree(pool); } static unsigned test_mempool_destructor_called; @@ -107,7 +107,7 @@ cxFree(pool->allocator, rdata); CX_TEST_ASSERT(test_mempool_destructor_called == 1); } - cxMempoolDestroy(pool); + cxMempoolFree(pool); } @@ -131,7 +131,7 @@ cxFree(pool->allocator, mem2); CX_TEST_ASSERT(pool->size == 3); } - cxMempoolDestroy(pool); + cxMempoolFree(pool); } CX_TEST(test_mempool_destroy) { @@ -146,7 +146,7 @@ CX_TEST_ASSERT(test_mempool_destructor_called == 1); data = cxMalloc(pool->allocator, sizeof(int)); cxMempoolSetDestructor(data, test_mempool_destructor); - cxMempoolDestroy(pool); + cxMempoolFree(pool); CX_TEST_ASSERT(test_mempool_destructor_called == 2); } } @@ -159,7 +159,7 @@ cxMempoolSetDestructor(data, test_mempool_destructor); int donotfree = 0; cxMempoolRegister(pool, &donotfree, test_mempool_destructor); - cxMempoolDestroy(pool); + cxMempoolFree(pool); CX_TEST_ASSERT(test_mempool_destructor_called == 2); } } diff -r 14ca894190fd -r b642eca4b956 tests/test_properties.c --- a/tests/test_properties.c Tue Nov 26 22:00:03 2024 +0100 +++ b/tests/test_properties.c Tue Nov 26 22:16:27 2024 +0100 @@ -440,7 +440,7 @@ char *v = cxMapGet(map, "key1"); CX_TEST_ASSERT(!strcmp(v, "value1")); - cxMapDestroy(map); + cxMapFree(map); cxPropertiesDestroy(&prop); CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); @@ -513,7 +513,7 @@ free(long_key); free(long_value); - cxMapDestroy(map); + cxMapFree(map); cxPropertiesDestroy(&prop); CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); diff -r 14ca894190fd -r b642eca4b956 tests/test_tree.c --- a/tests/test_tree.c Tue Nov 26 22:00:03 2024 +0100 +++ b/tests/test_tree.c Tue Nov 26 22:16:27 2024 +0100 @@ -1772,7 +1772,7 @@ CX_TEST_ASSERT(!cx_testing_allocator_verify(&talloc)); CX_TEST_ASSERT(talloc.alloc_total == 1); - cxTreeDestroy(tree); + cxTreeFree(tree); CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); } cx_testing_allocator_destroy(&talloc); @@ -1801,7 +1801,7 @@ CX_TEST_ASSERT(tree->loc_last_child == offsetof(struct cx_tree_node_base_s, last_child)); CX_TEST_ASSERT(tree->loc_prev == offsetof(struct cx_tree_node_base_s, prev)); CX_TEST_ASSERT(tree->loc_next == offsetof(struct cx_tree_node_base_s, next)); - cxTreeDestroy(tree); + cxTreeFree(tree); } } @@ -1827,7 +1827,7 @@ CX_TEST_ASSERT(tree->loc_last_child == -1); CX_TEST_ASSERT(tree->loc_prev == offsetof(tree_node, prev)); CX_TEST_ASSERT(tree->loc_next == offsetof(tree_node, next)); - cxTreeDestroy(tree); + cxTreeFree(tree); } } @@ -1852,9 +1852,9 @@ tree_node_file_layout ); CX_TEST_ASSERT(cxTreeDepth(empty) == 0); - cxTreeDestroy(empty); + cxTreeFree(empty); } - cxTreeDestroy(tree); + cxTreeFree(tree); } CX_TEST(test_tree_high_set_parent) { @@ -1884,9 +1884,9 @@ tree_node_file_layout ); CX_TEST_ASSERT(cxTreeDepth(empty) == 0); - cxTreeDestroy(empty); + cxTreeFree(empty); } - cxTreeDestroy(tree); + cxTreeFree(tree); } CX_TEST(test_tree_high_insert_one) { @@ -1916,7 +1916,7 @@ CX_TEST_ASSERT(talloc.alloc_total == 8); CX_TEST_ASSERT(talloc.free_total == 1); // the one that could not be added - cxTreeDestroy(tree); + cxTreeFree(tree); CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); } cx_testing_allocator_destroy(&talloc); @@ -1949,7 +1949,7 @@ CX_TEST_ASSERT(talloc.alloc_total == 8); CX_TEST_ASSERT(talloc.free_total == 1); // the one that could not be added - cxTreeDestroy(tree); + cxTreeFree(tree); CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); } cx_testing_allocator_destroy(&talloc); @@ -2044,7 +2044,7 @@ CX_TEST_ASSERT(NULL != cxTreeFind(tree, "/home/")); - cxTreeDestroy(tree); + cxTreeFree(tree); // we are not done yet, because we need to free the removed stuff CX_TEST_ASSERT(!cx_testing_allocator_verify(&talloc)); @@ -2054,7 +2054,7 @@ foo_tree->allocator = alloc; foo_tree->advanced_destructor = (cx_destructor_func2 ) cxFree; foo_tree->destructor_data = alloc; - cxTreeDestroy(foo_tree); + cxTreeFree(foo_tree); CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); } cx_testing_allocator_destroy(&talloc); @@ -2129,7 +2129,7 @@ CX_TEST_ASSERT(relinked_lib->parent == tree->root); CX_TEST_ASSERT(NULL != cxTreeFind(tree, "/home/")); - cxTreeDestroy(tree); + cxTreeFree(tree); // all memory should be free when using destroy instead of remove CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); } @@ -2168,14 +2168,14 @@ CX_TEST_ASSERT(tree->size == 0); CX_TEST_ASSERT(tree->root == NULL); CX_TEST_ASSERT(cxTreeDepth(tree) == 0); - cxTreeDestroy(tree); + cxTreeFree(tree); CX_TEST_ASSERT(!cx_testing_allocator_verify(&talloc)); CxTree *w = cxTreeCreateWrapped(alloc, root, tree_node_file_layout); w->advanced_destructor = (cx_destructor_func2) cxFree; w->destructor_data = alloc; cxTreeDestroySubtree(w, w->root); CX_TEST_ASSERT(!cx_testing_allocator_verify(&talloc)); - cxTreeDestroy(w); + cxTreeFree(w); CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); } cx_testing_allocator_destroy(&talloc); @@ -2194,7 +2194,7 @@ CxTree *tree = cxTreeCreateWrapped(cxDefaultAllocator, &root, tree_node_layout); tree->simple_destructor = test_tree_high_simple_destructor_func; cxTreeDestroyNode(tree, &child1, NULL); - cxTreeDestroy(tree); + cxTreeFree(tree); CX_TEST_ASSERT(root.data == 1); CX_TEST_ASSERT(child1.data == 1); CX_TEST_ASSERT(child2.data == 1);