--- a/src/cx/map.h Sun Dec 28 15:45:39 2025 +0100 +++ b/src/cx/map.h Sun Dec 28 17:31:20 2025 +0100 @@ -46,10 +46,6 @@ typedef struct cx_list_s CxList; #endif -#ifdef __cplusplus -extern "C" { -#endif - /** Type for the UCX map. */ typedef struct cx_map_s CxMap; @@ -227,8 +223,8 @@ * * @param map the map to be freed */ -CX_EXPORT void cxMapFree(CxMap *map); - +CX_EXTERN +void cxMapFree(CxMap *map); /** * Clears a map by removing all elements. @@ -237,8 +233,8 @@ * * @param map the map to be cleared */ -cx_attr_nonnull -CX_EXPORT void cxMapClear(CxMap *map); +CX_EXTERN CX_NONNULL +void cxMapClear(CxMap *map); /** * Returns the number of elements in this map. @@ -246,8 +242,8 @@ * @param map the map * @return the number of stored elements */ -cx_attr_nonnull -CX_EXPORT size_t cxMapSize(const CxMap *map); +CX_EXTERN CX_NONNULL +size_t cxMapSize(const CxMap *map); /** * Creates a value iterator for a map. @@ -262,8 +258,8 @@ * @param map the map to create the iterator for (can be @c NULL) * @return an iterator for the currently stored values */ -cx_attr_nodiscard -CX_EXPORT CxMapIterator cxMapIteratorValues(const CxMap *map); +CX_EXTERN CX_NODISCARD +CxMapIterator cxMapIteratorValues(const CxMap *map); /** * Creates a key iterator for a map. @@ -277,8 +273,8 @@ * @param map the map to create the iterator for (can be @c NULL) * @return an iterator for the currently stored keys */ -cx_attr_nodiscard -CX_EXPORT CxMapIterator cxMapIteratorKeys(const CxMap *map); +CX_EXTERN CX_NODISCARD +CxMapIterator cxMapIteratorKeys(const CxMap *map); /** * Creates an iterator for a map. @@ -294,8 +290,8 @@ * @see cxMapIteratorKeys() * @see cxMapIteratorValues() */ -cx_attr_nodiscard -CX_EXPORT CxMapIterator cxMapIterator(const CxMap *map); +CX_EXTERN CX_NODISCARD +CxMapIterator cxMapIterator(const CxMap *map); /** * Puts a key/value-pair into the map. @@ -317,8 +313,8 @@ * @retval non-zero value on memory allocation failure * @see cxMapPut() */ -cx_attr_nonnull -CX_EXPORT int cx_map_put(CxMap *map, CxHashKey key, void *value); +CX_EXTERN CX_NONNULL +int cx_map_put(CxMap *map, CxHashKey key, void *value); /** * Puts a key/value-pair into the map. @@ -359,8 +355,8 @@ * @return the pointer to the allocated memory or @c NULL if allocation fails * @see cxMapEmplace() */ -cx_attr_nonnull -CX_EXPORT void *cx_map_emplace(CxMap *map, CxHashKey key); +CX_EXTERN CX_NONNULL CX_NODISCARD +void *cx_map_emplace(CxMap *map, CxHashKey key); /** * Allocates memory for a value in the map associated with the specified key. @@ -393,8 +389,8 @@ * @return the value * @see cxMapGet() */ -cx_attr_nonnull cx_attr_nodiscard -CX_EXPORT void *cx_map_get(const CxMap *map, CxHashKey key); +CX_EXTERN CX_NONNULL CX_NODISCARD +void *cx_map_get(const CxMap *map, CxHashKey key); /** * Retrieves a value by using a key. @@ -436,8 +432,8 @@ * @see cxMapRemove() * @see cxMapRemoveAndGet() */ -cx_attr_nonnull_arg(1) -CX_EXPORT int cx_map_remove(CxMap *map, CxHashKey key, void *targetbuf); +CX_EXTERN CX_NONNULL_ARG(1) +int cx_map_remove(CxMap *map, CxHashKey key, void *targetbuf); /** * Removes a key/value-pair from the map by using the key. @@ -476,7 +472,6 @@ */ #define cxMapRemoveAndGet(map, key, targetbuf) cx_map_remove(map, CX_HASH_KEY(key), targetbuf) - /** * Performs a deep clone of one map into another. * @@ -499,11 +494,10 @@ * @retval zero when all elements were successfully cloned * @retval non-zero when an allocation error occurred */ -cx_attr_nonnull_arg(1, 2, 3) -CX_EXPORT int cxMapClone(CxMap *dst, const CxMap *src, +CX_EXTERN CX_NONNULL_ARG(1, 2, 3) +int cxMapClone(CxMap *dst, const CxMap *src, cx_clone_func clone_func, const CxAllocator *clone_allocator, void *data); - /** * Clones entries of a map if their key is not present in another map. * @@ -516,8 +510,8 @@ * @retval zero when the elements were successfully cloned * @retval non-zero when an allocation error occurred */ -cx_attr_nonnull_arg(1, 2, 3, 4) -CX_EXPORT int cxMapDifference(CxMap *dst, const CxMap *minuend, const CxMap *subtrahend, +CX_EXTERN CX_NONNULL_ARG(1, 2, 3, 4) +int cxMapDifference(CxMap *dst, const CxMap *minuend, const CxMap *subtrahend, cx_clone_func clone_func, const CxAllocator *clone_allocator, void *data); /** @@ -537,8 +531,8 @@ * @retval zero when the elements were successfully cloned * @retval non-zero when an allocation error occurred */ -cx_attr_nonnull_arg(1, 2, 3, 4) -CX_EXPORT int cxMapListDifference(CxMap *dst, const CxMap *src, const CxList *keys, +CX_EXTERN CX_NONNULL_ARG(1, 2, 3, 4) +int cxMapListDifference(CxMap *dst, const CxMap *src, const CxList *keys, cx_clone_func clone_func, const CxAllocator *clone_allocator, void *data); @@ -554,8 +548,8 @@ * @retval zero when the elements were successfully cloned * @retval non-zero when an allocation error occurred */ -cx_attr_nonnull_arg(1, 2, 3, 4) -CX_EXPORT int cxMapIntersection(CxMap *dst, const CxMap *src, const CxMap *other, +CX_EXTERN CX_NONNULL_ARG(1, 2, 3, 4) +int cxMapIntersection(CxMap *dst, const CxMap *src, const CxMap *other, cx_clone_func clone_func, const CxAllocator *clone_allocator, void *data); /** @@ -575,8 +569,8 @@ * @retval zero when the elements were successfully cloned * @retval non-zero when an allocation error occurred */ -cx_attr_nonnull_arg(1, 2, 3, 4) -CX_EXPORT int cxMapListIntersection(CxMap *dst, const CxMap *src, const CxList *keys, +CX_EXTERN CX_NONNULL_ARG(1, 2, 3, 4) +int cxMapListIntersection(CxMap *dst, const CxMap *src, const CxList *keys, cx_clone_func clone_func, const CxAllocator *clone_allocator, void *data); /** @@ -595,8 +589,8 @@ * @retval zero when the elements were successfully cloned * @retval non-zero when an allocation error occurred */ -cx_attr_nonnull_arg(1, 2, 3) -CX_EXPORT int cxMapUnion(CxMap *dst, const CxMap *src, +CX_EXTERN CX_NONNULL_ARG(1, 2, 3) +int cxMapUnion(CxMap *dst, const CxMap *src, cx_clone_func clone_func, const CxAllocator *clone_allocator, void *data); /** @@ -622,8 +616,8 @@ * @retval non-zero when an allocation error occurred * @see cxMapClone() */ -cx_attr_nonnull -CX_EXPORT int cxMapCloneShallow(CxMap *dst, const CxMap *src); +CX_EXTERN CX_NONNULL +int cxMapCloneShallow(CxMap *dst, const CxMap *src); /** * Clones entries of a map if their key is not present in another map. @@ -637,8 +631,8 @@ * @retval zero when the elements were successfully cloned * @retval non-zero when an allocation error occurred */ -cx_attr_nonnull -CX_EXPORT int cxMapDifferenceShallow(CxMap *dst, const CxMap *minuend, const CxMap *subtrahend); +CX_EXTERN CX_NONNULL +int cxMapDifferenceShallow(CxMap *dst, const CxMap *minuend, const CxMap *subtrahend); /** * Clones entries of a map if their key is not present in a list. @@ -658,9 +652,8 @@ * @retval non-zero when an allocation error occurred * @see cxMapListDifference() */ -cx_attr_nonnull -CX_EXPORT int cxMapListDifferenceShallow(CxMap *dst, const CxMap *src, const CxList *keys); - +CX_EXTERN CX_NONNULL +int cxMapListDifferenceShallow(CxMap *dst, const CxMap *src, const CxList *keys); /** * Clones entries of a map only if their key is present in another map. @@ -674,8 +667,8 @@ * @retval zero when the elements were successfully cloned * @retval non-zero when an allocation error occurred */ -cx_attr_nonnull -CX_EXPORT int cxMapIntersectionShallow(CxMap *dst, const CxMap *src, const CxMap *other); +CX_EXTERN CX_NONNULL +int cxMapIntersectionShallow(CxMap *dst, const CxMap *src, const CxMap *other); /** * Clones entries of a map only if their key is present in a list. @@ -694,8 +687,8 @@ * @retval zero when the elements were successfully cloned * @retval non-zero when an allocation error occurred */ -cx_attr_nonnull -CX_EXPORT int cxMapListIntersectionShallow(CxMap *dst, const CxMap *src, const CxList *keys); +CX_EXTERN CX_NONNULL +int cxMapListIntersectionShallow(CxMap *dst, const CxMap *src, const CxList *keys); /** * Clones entries into a map if their key does not exist yet. @@ -713,9 +706,8 @@ * @retval zero when the elements were successfully cloned * @retval non-zero when an allocation error occurred */ -cx_attr_nonnull -CX_EXPORT int cxMapUnionShallow(CxMap *dst, const CxMap *src); - +CX_EXTERN CX_NONNULL +int cxMapUnionShallow(CxMap *dst, const CxMap *src); /** * Compares the entries of two maps. @@ -729,11 +721,7 @@ * @retval non-zero (unspecified whether positive or negative) when the size * of both maps is equal but a key or a value is different */ -cx_attr_nonnull -CX_EXPORT int cxMapCompare(const CxMap *map, const CxMap *other); - -#ifdef __cplusplus -} // extern "C" -#endif +CX_EXTERN CX_NONNULL +int cxMapCompare(const CxMap *map, const CxMap *other); #endif // UCX_MAP_H