src/cx/allocator.h

changeset 500
eb9e7bd40a8e
parent 484
9e6900b1cf9d
child 503
a89857072ace
     1.1 --- a/src/cx/allocator.h	Sat Jan 29 14:32:04 2022 +0100
     1.2 +++ b/src/cx/allocator.h	Sun Jan 30 14:19:00 2022 +0100
     1.3 @@ -83,12 +83,12 @@
     1.4  /**
     1.5   * High-Level type alias for the allocator type.
     1.6   */
     1.7 -typedef struct cx_allocator_s *CxAllocator;
     1.8 +typedef struct cx_allocator_s CxAllocator;
     1.9  
    1.10  /**
    1.11   * A default allocator using standard library malloc() etc.
    1.12   */
    1.13 -extern CxAllocator cxDefaultAllocator;
    1.14 +extern CxAllocator *cxDefaultAllocator;
    1.15  
    1.16  /**
    1.17   * Allocate \p n bytes of memory.
    1.18 @@ -97,7 +97,10 @@
    1.19   * @param n the number of bytes
    1.20   * @return a pointer to the allocated memory
    1.21   */
    1.22 -void *cxMalloc(CxAllocator allocator, size_t n)
    1.23 +void *cxMalloc(
    1.24 +        CxAllocator *allocator,
    1.25 +        size_t n
    1.26 +)
    1.27  __attribute__((__malloc__))
    1.28  __attribute__((__alloc_size__(2)));
    1.29  
    1.30 @@ -113,7 +116,11 @@
    1.31   * @param n the new size in bytes
    1.32   * @return a pointer to the re-allocated memory
    1.33   */
    1.34 -void *cxRealloc(CxAllocator allocator, void *mem, size_t n)
    1.35 +void *cxRealloc(
    1.36 +        CxAllocator *allocator,
    1.37 +        void *mem,
    1.38 +        size_t n
    1.39 +)
    1.40  __attribute__((__warn_unused_result__))
    1.41  __attribute__((__alloc_size__(3)));
    1.42  
    1.43 @@ -132,7 +139,11 @@
    1.44   * @param n the new size in bytes
    1.45   * @return zero on success, non-zero on failure
    1.46   */
    1.47 -int cxReallocate(CxAllocator allocator, void **mem, size_t n)
    1.48 +int cxReallocate(
    1.49 +        CxAllocator *allocator,
    1.50 +        void **mem,
    1.51 +        size_t n
    1.52 +)
    1.53  __attribute__((__nonnull__));
    1.54  
    1.55  /**
    1.56 @@ -143,7 +154,11 @@
    1.57   * @param n the size of each element in bytes
    1.58   * @return a pointer to the allocated memory
    1.59   */
    1.60 -void *cxCalloc(CxAllocator allocator, size_t nelem, size_t n)
    1.61 +void *cxCalloc(
    1.62 +        CxAllocator *allocator,
    1.63 +        size_t nelem,
    1.64 +        size_t n
    1.65 +)
    1.66  __attribute__((__malloc__))
    1.67  __attribute__((__alloc_size__(2, 3)));
    1.68  
    1.69 @@ -155,7 +170,10 @@
    1.70   * @param allocator the allocator
    1.71   * @param mem a pointer to the block to free
    1.72   */
    1.73 -void cxFree(CxAllocator allocator, void *mem)
    1.74 +void cxFree(
    1.75 +        CxAllocator *allocator,
    1.76 +        void *mem
    1.77 +)
    1.78  __attribute__((__nonnull__));
    1.79  
    1.80  #ifdef __cplusplus

mercurial