Sun, 14 Dec 2025 16:21:09 +0100
rename the "simple" cloning functions from Simple to Shallow
relates to #780
| docs/Writerside/topics/list.h.md | file | annotate | diff | comparison | revisions | |
| docs/Writerside/topics/map.h.md | file | annotate | diff | comparison | revisions | |
| src/cx/list.h | file | annotate | diff | comparison | revisions | |
| src/cx/map.h | file | annotate | diff | comparison | revisions | |
| src/list.c | file | annotate | diff | comparison | revisions | |
| src/map.c | file | annotate | diff | comparison | revisions | |
| tests/test_hash_map.c | file | annotate | diff | comparison | revisions | |
| tests/test_list.c | file | annotate | diff | comparison | revisions |
--- a/docs/Writerside/topics/list.h.md Sun Dec 14 16:15:57 2025 +0100 +++ b/docs/Writerside/topics/list.h.md Sun Dec 14 16:21:09 2025 +0100 @@ -369,7 +369,7 @@ const CxAllocator *clone_allocator, void *data); -int cxListCloneSimple(CxList *dst, const CxList *src); +int cxListCloneShallow(CxList *dst, const CxList *src); int cxListDifference(CxList *dst, const CxList *minuend, const CxList *subtrahend, @@ -377,7 +377,7 @@ const CxAllocator *clone_allocator, void *data); -int cxListDifferenceSimple(CxList *dst, +int cxListDifferenceShallow(CxList *dst, const CxList *minuend, const CxList *subtrahend); int cxListIntersection(CxList *dst, @@ -386,7 +386,7 @@ const CxAllocator *clone_allocator, void *data); -int cxListIntersectionSimple(CxList *dst, +int cxListIntersectionShallow(CxList *dst, const CxList *src, const CxList *other); int cxListUnion(CxList *dst, @@ -395,7 +395,7 @@ const CxAllocator *clone_allocator, void *data); -int cxListUnionSimple(CxList *dst, +int cxListUnionShallow(CxList *dst, const CxList *src, const CxList *other); ```
--- a/docs/Writerside/topics/map.h.md Sun Dec 14 16:15:57 2025 +0100 +++ b/docs/Writerside/topics/map.h.md Sun Dec 14 16:21:09 2025 +0100 @@ -316,7 +316,7 @@ const CxAllocator *clone_allocator, void *data); -int cxMapCloneSimple(CxMap *dst, const CxMap *src); +int cxMapCloneShallow(CxMap *dst, const CxMap *src); int cxMapDifference(CxMap *dst, const CxMap *minuend, const CxMap *subtrahend, @@ -324,7 +324,7 @@ const CxAllocator *clone_allocator, void *data); -int cxMapDifferenceSimple(CxMap *dst, +int cxMapDifferenceShallow(CxMap *dst, const CxMap *minuend, const CxMap *subtrahend); int cxMapListDifference(CxMap *dst, @@ -333,7 +333,7 @@ const CxAllocator *clone_allocator, void *data); -int cxMapListDifferenceSimple(CxMap *dst, +int cxMapListDifferenceShallow(CxMap *dst, const CxMap *src, const CxList *keys); int cxMapIntersection(CxMap *dst, @@ -342,7 +342,7 @@ const CxAllocator *clone_allocator, void *data); -int cxMapIntersectionSimple(CxMap *dst, +int cxMapIntersectionShallow(CxMap *dst, const CxMap *src, const CxMap *other); int cxMapListIntersection(CxMap *dst, @@ -351,7 +351,7 @@ const CxAllocator *clone_allocator, void *data); -int cxMapListIntersectionSimple(CxMap *dst, +int cxMapListIntersectionShallow(CxMap *dst, const CxMap *src, const CxList *keys); int cxMapUnion(CxMap *dst, const CxMap *src, @@ -359,7 +359,7 @@ const CxAllocator *clone_allocator, void *data); -int cxMapUnionSimple(CxMap *dst, const CxMap *src); +int cxMapUnionShallow(CxMap *dst, const CxMap *src); ``` With `cxMapClone()` you can create deep copies of the values in one map and insert them into another map.
--- a/src/cx/list.h Sun Dec 14 16:15:57 2025 +0100 +++ b/src/cx/list.h Sun Dec 14 16:21:09 2025 +0100 @@ -984,7 +984,7 @@ * @param data optional additional data that is passed to the clone function * @retval zero when all elements were successfully cloned * @retval non-zero when an allocation error occurred - * @see cxListCloneSimple() + * @see cxListCloneShallow() */ cx_attr_nonnull_arg(1, 2, 3) CX_EXPORT int cxListClone(CxList *dst, const CxList *src, @@ -1007,7 +1007,7 @@ * @param data optional additional data that is passed to the clone function * @retval zero when the elements were successfully cloned * @retval non-zero when an allocation error occurred - * @see cxListDifferenceSimple() + * @see cxListDifferenceShallow() */ cx_attr_nonnull_arg(1, 2, 3, 4) CX_EXPORT int cxListDifference(CxList *dst, @@ -1031,7 +1031,7 @@ * @param data optional additional data that is passed to the clone function * @retval zero when the elements were successfully cloned * @retval non-zero when an allocation error occurred - * @see cxListIntersectionSimple() + * @see cxListIntersectionShallow() */ cx_attr_nonnull_arg(1, 2, 3, 4) CX_EXPORT int cxListIntersection(CxList *dst, const CxList *src, const CxList *other, @@ -1056,7 +1056,7 @@ * @param data optional additional data that is passed to the clone function * @retval zero when the elements were successfully cloned * @retval non-zero when an allocation error occurred - * @see cxListUnionSimple() + * @see cxListUnionShallow() */ cx_attr_nonnull_arg(1, 2, 3, 4) CX_EXPORT int cxListUnion(CxList *dst, const CxList *src, const CxList *other, @@ -1082,7 +1082,7 @@ * @see cxListClone() */ cx_attr_nonnull -CX_EXPORT int cxListCloneSimple(CxList *dst, const CxList *src); +CX_EXPORT int cxListCloneShallow(CxList *dst, const CxList *src); /** * Clones elements from a list only if they are not present in another list. @@ -1104,7 +1104,7 @@ * @see cxListDifference() */ cx_attr_nonnull -CX_EXPORT int cxListDifferenceSimple(CxList *dst, +CX_EXPORT int cxListDifferenceShallow(CxList *dst, const CxList *minuend, const CxList *subtrahend); /** @@ -1127,7 +1127,7 @@ * @see cxListIntersection() */ cx_attr_nonnull -CX_EXPORT int cxListIntersectionSimple(CxList *dst, const CxList *src, const CxList *other); +CX_EXPORT int cxListIntersectionShallow(CxList *dst, const CxList *src, const CxList *other); /** * Performs a deep clone of one list into another, skipping duplicates. @@ -1151,7 +1151,7 @@ * @see cxListUnion() */ cx_attr_nonnull -CX_EXPORT int cxListUnionSimple(CxList *dst, const CxList *src, const CxList *other); +CX_EXPORT int cxListUnionShallow(CxList *dst, const CxList *src, const CxList *other); /** * Asks the list to reserve enough memory for a given total number of elements.
--- a/src/cx/map.h Sun Dec 14 16:15:57 2025 +0100 +++ b/src/cx/map.h Sun Dec 14 16:21:09 2025 +0100 @@ -623,7 +623,7 @@ * @see cxMapClone() */ cx_attr_nonnull -CX_EXPORT int cxMapCloneSimple(CxMap *dst, const CxMap *src); +CX_EXPORT int cxMapCloneShallow(CxMap *dst, const CxMap *src); /** * Clones entries of a map if their key is not present in another map. @@ -638,7 +638,7 @@ * @retval non-zero when an allocation error occurred */ cx_attr_nonnull -CX_EXPORT int cxMapDifferenceSimple(CxMap *dst, const CxMap *minuend, const CxMap *subtrahend); +CX_EXPORT int cxMapDifferenceShallow(CxMap *dst, const CxMap *minuend, const CxMap *subtrahend); /** * Clones entries of a map if their key is not present in a list. @@ -659,7 +659,7 @@ * @see cxMapListDifference() */ cx_attr_nonnull -CX_EXPORT int cxMapListDifferenceSimple(CxMap *dst, const CxMap *src, const CxList *keys); +CX_EXPORT int cxMapListDifferenceShallow(CxMap *dst, const CxMap *src, const CxList *keys); /** @@ -675,7 +675,7 @@ * @retval non-zero when an allocation error occurred */ cx_attr_nonnull -CX_EXPORT int cxMapIntersectionSimple(CxMap *dst, const CxMap *src, const CxMap *other); +CX_EXPORT int cxMapIntersectionShallow(CxMap *dst, const CxMap *src, const CxMap *other); /** * Clones entries of a map only if their key is present in a list. @@ -695,7 +695,7 @@ * @retval non-zero when an allocation error occurred */ cx_attr_nonnull -CX_EXPORT int cxMapListIntersectionSimple(CxMap *dst, const CxMap *src, const CxList *keys); +CX_EXPORT int cxMapListIntersectionShallow(CxMap *dst, const CxMap *src, const CxList *keys); /** * Clones entries into a map if their key does not exist yet. @@ -714,7 +714,7 @@ * @retval non-zero when an allocation error occurred */ cx_attr_nonnull -CX_EXPORT int cxMapUnionSimple(CxMap *dst, const CxMap *src); +CX_EXPORT int cxMapUnionShallow(CxMap *dst, const CxMap *src); /**
--- a/src/list.c Sun Dec 14 16:15:57 2025 +0100 +++ b/src/list.c Sun Dec 14 16:21:09 2025 +0100 @@ -1097,19 +1097,19 @@ return 0; } -int cxListCloneSimple(CxList *dst, const CxList *src) { +int cxListCloneShallow(CxList *dst, const CxList *src) { return cxListClone(dst, src, use_simple_clone_func(src)); } -int cxListDifferenceSimple(CxList *dst, const CxList *minuend, const CxList *subtrahend) { +int cxListDifferenceShallow(CxList *dst, const CxList *minuend, const CxList *subtrahend) { return cxListDifference(dst, minuend, subtrahend, use_simple_clone_func(minuend)); } -int cxListIntersectionSimple(CxList *dst, const CxList *src, const CxList *other) { +int cxListIntersectionShallow(CxList *dst, const CxList *src, const CxList *other) { return cxListIntersection(dst, src, other, use_simple_clone_func(src)); } -int cxListUnionSimple(CxList *dst, const CxList *src, const CxList *other) { +int cxListUnionShallow(CxList *dst, const CxList *src, const CxList *other) { return cxListUnion(dst, src, other, use_simple_clone_func(src)); }
--- a/src/map.c Sun Dec 14 16:15:57 2025 +0100 +++ b/src/map.c Sun Dec 14 16:21:09 2025 +0100 @@ -305,27 +305,27 @@ return 0; } -int cxMapCloneSimple(CxMap *dst, const CxMap *src) { +int cxMapCloneShallow(CxMap *dst, const CxMap *src) { return cxMapClone(dst, src, use_simple_clone_func(src)); } -int cxMapDifferenceSimple(CxMap *dst, const CxMap *minuend, const CxMap *subtrahend) { +int cxMapDifferenceShallow(CxMap *dst, const CxMap *minuend, const CxMap *subtrahend) { return cxMapDifference(dst, minuend, subtrahend, use_simple_clone_func(minuend)); } -int cxMapListDifferenceSimple(CxMap *dst, const CxMap *src, const CxList *keys) { +int cxMapListDifferenceShallow(CxMap *dst, const CxMap *src, const CxList *keys) { return cxMapListDifference(dst, src, keys, use_simple_clone_func(src)); } -int cxMapIntersectionSimple(CxMap *dst, const CxMap *src, const CxMap *other) { +int cxMapIntersectionShallow(CxMap *dst, const CxMap *src, const CxMap *other) { return cxMapIntersection(dst, src, other, use_simple_clone_func(src)); } -int cxMapListIntersectionSimple(CxMap *dst, const CxMap *src, const CxList *keys) { +int cxMapListIntersectionShallow(CxMap *dst, const CxMap *src, const CxList *keys) { return cxMapListIntersection(dst, src, keys, use_simple_clone_func(src)); } -int cxMapUnionSimple(CxMap *dst, const CxMap *src) { +int cxMapUnionShallow(CxMap *dst, const CxMap *src) { return cxMapUnion(dst, src, use_simple_clone_func(src)); }
--- a/tests/test_hash_map.c Sun Dec 14 16:15:57 2025 +0100 +++ b/tests/test_hash_map.c Sun Dec 14 16:21:09 2025 +0100 @@ -1203,7 +1203,7 @@ CxMap *d2 = cxHashMapCreateSimple(sizeof(int)); CX_TEST_DO { - CX_TEST_ASSERT(0 == cxMapCloneSimple(d1, a)); + CX_TEST_ASSERT(0 == cxMapCloneShallow(d1, a)); CX_TEST_ASSERT(!cxMapContains(d1, "k0")); CX_TEST_ASSERT(cxMapContains(d1, "k1")); CX_TEST_ASSERT(cxMapContains(d1, "k2")); @@ -1211,7 +1211,7 @@ CX_TEST_ASSERT(cxMapContains(d1, "k4")); CX_TEST_ASSERT(!cxMapContains(d1, "k5")); - CX_TEST_ASSERT(0 == cxMapListDifferenceSimple(d2, d1, kl1)); + CX_TEST_ASSERT(0 == cxMapListDifferenceShallow(d2, d1, kl1)); CX_TEST_ASSERT(!cxMapContains(d2, "k0")); CX_TEST_ASSERT(cxMapContains(d2, "k1")); CX_TEST_ASSERT(!cxMapContains(d2, "k2")); @@ -1220,14 +1220,14 @@ CX_TEST_ASSERT(!cxMapContains(d2, "k5")); cxMapClear(d1); - CX_TEST_ASSERT(0 == cxMapListIntersectionSimple(d1, d2, kl2)); + CX_TEST_ASSERT(0 == cxMapListIntersectionShallow(d1, d2, kl2)); CX_TEST_ASSERT(!cxMapContains(d1, "k0")); CX_TEST_ASSERT(!cxMapContains(d1, "k1")); CX_TEST_ASSERT(!cxMapContains(d1, "k2")); CX_TEST_ASSERT(cxMapContains(d1, "k3")); CX_TEST_ASSERT(cxMapContains(d1, "k4")); - CX_TEST_ASSERT(0 == cxMapUnionSimple(d1, b)); + CX_TEST_ASSERT(0 == cxMapUnionShallow(d1, b)); CX_TEST_ASSERT(cxMapContains(d1, "k0")); CX_TEST_ASSERT(!cxMapContains(d1, "k1")); CX_TEST_ASSERT(cxMapContains(d1, "k2")); @@ -1236,7 +1236,7 @@ CX_TEST_ASSERT(cxMapContains(d1, "k5")); cxMapClear(d2); - CX_TEST_ASSERT(0 == cxMapDifferenceSimple(d2, d1, a)); + CX_TEST_ASSERT(0 == cxMapDifferenceShallow(d2, d1, a)); CX_TEST_ASSERT(cxMapContains(d2, "k0")); CX_TEST_ASSERT(!cxMapContains(d2, "k1")); CX_TEST_ASSERT(!cxMapContains(d2, "k2")); @@ -1245,7 +1245,7 @@ CX_TEST_ASSERT(cxMapContains(d2, "k5")); cxMapClear(d1); - CX_TEST_ASSERT(0 == cxMapIntersectionSimple(d1, d2, c)); + CX_TEST_ASSERT(0 == cxMapIntersectionShallow(d1, d2, c)); CX_TEST_ASSERT(!cxMapContains(d1, "k0")); CX_TEST_ASSERT(!cxMapContains(d1, "k1")); CX_TEST_ASSERT(!cxMapContains(d1, "k2"));
--- a/tests/test_list.c Sun Dec 14 16:15:57 2025 +0100 +++ b/tests/test_list.c Sun Dec 14 16:21:09 2025 +0100 @@ -3255,12 +3255,12 @@ CX_TEST_DO { // clone a into d1 - CX_TEST_ASSERT(0 == cxListCloneSimple(d1, la)); + CX_TEST_ASSERT(0 == cxListCloneShallow(d1, la)); CX_TEST_ASSERT(0 == cxListCompare(d1, la)); CX_TEST_ASSERT(cxCollectionSorted(d1)); // union of a (in d1) and b - CX_TEST_ASSERT(0 == cxListUnionSimple(d2, d1, lb)); + CX_TEST_ASSERT(0 == cxListUnionShallow(d2, d1, lb)); CX_TEST_ASSERT(cxCollectionSorted(d2)); CxList *expected_union = cxArrayListCreateSimple(sizeof(int), 8); { @@ -3272,7 +3272,7 @@ // intersection of (a union b) and c cxListClear(d1); - CX_TEST_ASSERT(0 == cxListIntersectionSimple(d1, d2, lc)); + CX_TEST_ASSERT(0 == cxListIntersectionShallow(d1, d2, lc)); CX_TEST_ASSERT(cxCollectionSorted(d1)); CxList *expected_intersection = cxArrayListCreateSimple(sizeof(int), 8); { @@ -3284,7 +3284,7 @@ // difference of ((a union b) intersect c) minus d cxListClear(d2); - CX_TEST_ASSERT(0 == cxListDifferenceSimple(d2, d1, ld)); + CX_TEST_ASSERT(0 == cxListDifferenceShallow(d2, d1, ld)); CX_TEST_ASSERT(cxCollectionSorted(d2)); CxList *expected_difference = cxArrayListCreateSimple(sizeof(int), 8); {