src/cx/allocator.h

changeset 1675
36c0fb2b60b2
parent 1610
ce0b0bf7d29c
--- a/src/cx/allocator.h	Sun Dec 28 15:45:39 2025 +0100
+++ b/src/cx/allocator.h	Sun Dec 28 17:31:20 2025 +0100
@@ -35,10 +35,6 @@
 
 #include "common.h"
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 /**
  * The class definition for an allocator.
  */
@@ -153,8 +149,8 @@
  *
  * @return the system's memory page size in bytes
  */
-cx_attr_nodiscard
-CX_EXPORT unsigned long cx_system_page_size(void);
+CX_EXTERN CX_NODISCARD
+unsigned long cx_system_page_size(void);
 
 /**
  * Reallocate a previously allocated block.
@@ -167,8 +163,8 @@
  * @retval non-zero failure
  * @see cx_reallocatearray()
  */
-cx_attr_nonnull cx_attr_nodiscard
-CX_EXPORT int cx_reallocate_(void **mem, size_t n);
+CX_EXTERN CX_NONNULL CX_NODISCARD
+int cx_reallocate_(void **mem, size_t n);
 
 /**
  * Reallocate a previously allocated block.
@@ -182,8 +178,8 @@
  * @retval non-zero failure
  * @see cx_reallocate()
  */
-cx_attr_nonnull cx_attr_nodiscard
-CX_EXPORT int cx_reallocatearray_(void **mem, size_t nmemb, size_t size);
+CX_EXTERN CX_NONNULL CX_NODISCARD
+int cx_reallocatearray_(void **mem, size_t nmemb, size_t size);
 
 /**
  * Reallocate a previously allocated block and changes the pointer in-place,
@@ -239,8 +235,8 @@
  * @param allocator the allocator
  * @param mem a pointer to the block to free
  */
-cx_attr_nonnull_arg(1)
-CX_EXPORT void cxFree(const CxAllocator *allocator, void *mem);
+CX_EXTERN CX_NONNULL_ARG(1)
+void cxFree(const CxAllocator *allocator, void *mem);
 
 /**
  * Allocate @p n bytes of memory.
@@ -249,9 +245,9 @@
  * @param n the number of bytes
  * @return a pointer to the allocated memory
  */
-cx_attr_nodiscard cx_attr_nonnull
-cx_attr_malloc cx_attr_dealloc_ucx cx_attr_allocsize(2)
-CX_EXPORT void *cxMalloc(const CxAllocator *allocator, size_t n);
+CX_EXTERN CX_NODISCARD CX_NONNULL
+CX_MALLOC CX_DEALLOC_UCX CX_ALLOCSIZE(2)
+void *cxMalloc(const CxAllocator *allocator, size_t n);
 
 /**
  * Reallocate the previously allocated block in @p mem, making the new block
@@ -268,9 +264,9 @@
  * @param n the new size in bytes
  * @return a pointer to the reallocated memory
  */
-cx_attr_nodiscard cx_attr_nonnull_arg(1)
-cx_attr_dealloc_ucx cx_attr_allocsize(3)
-CX_EXPORT void *cxRealloc(const CxAllocator *allocator, void *mem, size_t n);
+CX_EXTERN CX_NODISCARD CX_NONNULL_ARG(1)
+CX_DEALLOC_UCX CX_ALLOCSIZE(3)
+void *cxRealloc(const CxAllocator *allocator, void *mem, size_t n);
 
 /**
  * Reallocate the previously allocated block in @p mem.
@@ -292,9 +288,9 @@
  * @param size the size of each element
  * @return a pointer to the reallocated memory
  */
-cx_attr_nodiscard cx_attr_nonnull_arg(1)
-cx_attr_dealloc_ucx cx_attr_allocsize(3, 4)
-CX_EXPORT void *cxReallocArray(const CxAllocator *allocator,
+CX_EXTERN CX_NODISCARD CX_NONNULL_ARG(1)
+CX_DEALLOC_UCX CX_ALLOCSIZE(3, 4)
+void *cxReallocArray(const CxAllocator *allocator,
         void *mem, size_t nmemb, size_t size);
 
 /**
@@ -308,8 +304,8 @@
  * @retval zero success
  * @retval non-zero failure
  */
-cx_attr_nodiscard cx_attr_nonnull
-CX_EXPORT int cxReallocate_(const CxAllocator *allocator, void **mem, size_t n);
+CX_EXTERN CX_NODISCARD CX_NONNULL
+int cxReallocate_(const CxAllocator *allocator, void **mem, size_t n);
 
 /**
  * Reallocate a previously allocated block and changes the pointer in-place,
@@ -342,8 +338,8 @@
  * @retval zero success
  * @retval non-zero on failure
  */
-cx_attr_nodiscard cx_attr_nonnull
-CX_EXPORT int cxReallocateArray_(const CxAllocator *allocator,
+CX_EXTERN CX_NODISCARD CX_NONNULL
+int cxReallocateArray_(const CxAllocator *allocator,
         void **mem, size_t nmemb, size_t size);
 
 /**
@@ -376,9 +372,9 @@
  * @param size the size of each element in bytes
  * @return a pointer to the allocated memory
  */
-cx_attr_nonnull_arg(1) cx_attr_nodiscard
-cx_attr_malloc cx_attr_dealloc_ucx cx_attr_allocsize(2, 3)
-CX_EXPORT void *cxCalloc(const CxAllocator *allocator, size_t nmemb, size_t size);
+CX_EXTERN CX_NONNULL_ARG(1) CX_NODISCARD
+CX_MALLOC CX_DEALLOC_UCX CX_ALLOCSIZE(2, 3)
+void *cxCalloc(const CxAllocator *allocator, size_t nmemb, size_t size);
 
 /**
  * Allocate @p n bytes of memory and sets every byte to zero.
@@ -387,9 +383,9 @@
  * @param n the number of bytes
  * @return a pointer to the allocated memory
  */
-cx_attr_nodiscard cx_attr_nonnull
-cx_attr_malloc cx_attr_dealloc_ucx cx_attr_allocsize(2)
-CX_EXPORT void *cxZalloc(const CxAllocator *allocator, size_t n);
+CX_EXTERN CX_NODISCARD CX_NONNULL
+CX_MALLOC CX_DEALLOC_UCX CX_ALLOCSIZE(2)
+void *cxZalloc(const CxAllocator *allocator, size_t n);
 
 /**
  * Allocate @p n bytes of memory.
@@ -510,10 +506,7 @@
  *
  * @param mem the memory to deallocate
  */
-CX_EXPORT void cxFreeDefault(void *mem);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+CX_EXTERN
+void cxFreeDefault(void *mem);
 
 #endif // UCX_ALLOCATOR_H

mercurial