src/cx/kv_list.h

changeset 1675
36c0fb2b60b2
parent 1605
55b13f583356
--- a/src/cx/kv_list.h	Sun Dec 28 15:45:39 2025 +0100
+++ b/src/cx/kv_list.h	Sun Dec 28 17:31:20 2025 +0100
@@ -40,10 +40,6 @@
 #include "list.h"
 #include "map.h"
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 /**
  * Allocates a linked list with a lookup-map for storing elements with @p elem_size bytes each.
  *
@@ -63,8 +59,8 @@
  * @see cxKvListAsMap()
  * @see cxKvListAsList()
  */
-cx_attr_nodiscard cx_attr_malloc cx_attr_dealloc(cxListFree, 1)
-CX_EXPORT CxList *cxKvListCreate(const CxAllocator *allocator,
+CX_EXTERN CX_NODISCARD CX_MALLOC CX_DEALLOC(cxListFree, 1)
+CxList *cxKvListCreate(const CxAllocator *allocator,
         size_t elem_size);
 
 /**
@@ -85,8 +81,8 @@
  * @see cxKvListAsMap()
  * @see cxKvListAsList()
  */
-cx_attr_nodiscard cx_attr_malloc cx_attr_dealloc(cxMapFree, 1)
-CX_EXPORT CxMap *cxKvListCreateAsMap(const CxAllocator *allocator,
+CX_EXTERN CX_NODISCARD CX_MALLOC CX_DEALLOC(cxMapFree, 1)
+CxMap *cxKvListCreateAsMap(const CxAllocator *allocator,
         size_t elem_size);
 
 /**
@@ -95,8 +91,8 @@
  * @param map a map pointer that was returned by a call to cxKvListAsMap()
  * @return the original list pointer
  */
-cx_attr_nodiscard cx_attr_nonnull cx_attr_returns_nonnull
-CX_EXPORT CxList *cxKvListAsList(CxMap *map);
+CX_EXTERN CX_NODISCARD CX_NONNULL CX_RETURNS_NONNULL
+CxList *cxKvListAsList(CxMap *map);
 
 /**
  * Converts a map pointer belonging to a key-value-List back to the original list pointer.
@@ -104,8 +100,8 @@
  * @param list a list created by cxKvListCreate()
  * @return a map pointer that lets you use the list as if it was a map
  */
-cx_attr_nodiscard cx_attr_nonnull cx_attr_returns_nonnull
-CX_EXPORT CxMap *cxKvListAsMap(CxList *list);
+CX_EXTERN CX_NODISCARD CX_NONNULL CX_RETURNS_NONNULL
+CxMap *cxKvListAsMap(CxList *list);
 
 /**
  * Sets or updates the key of a list item.
@@ -120,8 +116,8 @@
  * @retval non-zero memory allocation failure or the index is out of bounds
  * @see cxKvListSetKey()
  */
-cx_attr_nonnull
-CX_EXPORT int cx_kv_list_set_key(CxList *list, size_t index, CxHashKey key);
+CX_EXTERN CX_NONNULL
+int cx_kv_list_set_key(CxList *list, size_t index, CxHashKey key);
 
 /**
  * Inserts an item into the list at the specified index and associates it with the specified key.
@@ -134,8 +130,8 @@
  * @retval non-zero memory allocation failure or the index is out of bounds
  * @see cxKvListInsert()
  */
-cx_attr_nonnull
-CX_EXPORT int cx_kv_list_insert(CxList *list, size_t index, CxHashKey key, void *value);
+CX_EXTERN CX_NONNULL
+int cx_kv_list_insert(CxList *list, size_t index, CxHashKey key, void *value);
 
 /**
  * Sets or updates the key of a list item.
@@ -165,7 +161,6 @@
  */
 #define cxKvListInsert(list, index, key, value) cx_kv_list_insert(list, index, CX_HASH_KEY(key), value)
 
-
 /**
  * Removes the key of a list item.
  *
@@ -178,8 +173,8 @@
  * @retval zero success
  * @retval non-zero the index is out of bounds
  */
-cx_attr_nonnull
-CX_EXPORT int cxKvListRemoveKey(CxList *list, size_t index);
+CX_EXTERN CX_NONNULL
+int cxKvListRemoveKey(CxList *list, size_t index);
 
 /**
  * Returns the key of a list item.
@@ -188,8 +183,8 @@
  * @param index the index of the element in the list
  * @return a pointer to the key or @c NULL when the index is out of bounds or the item does not have a key
  */
-cx_attr_nonnull
-CX_EXPORT const CxHashKey *cxKvListGetKey(CxList *list, size_t index);
+CX_EXTERN CX_NONNULL CX_NODISCARD
+const CxHashKey *cxKvListGetKey(CxList *list, size_t index);
 
 /**
  * Adds an item into the list and associates it with the specified key.
@@ -202,8 +197,4 @@
  */
 #define cxKvListAdd(list, key, value) cxKvListInsert(list, (list)->collection.size, key, value)
 
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
 #endif // UCX_KV_LIST_H

mercurial