do not hide pointers behind typedefs

Sun, 30 Jan 2022 14:19:00 +0100

author
Mike Becker <universe@uap-core.de>
date
Sun, 30 Jan 2022 14:19:00 +0100
changeset 500
eb9e7bd40a8e
parent 499
3dc9075df822
child 501
9a08f5e515cc

do not hide pointers behind typedefs

src/allocator.c file | annotate | diff | comparison | revisions
src/buffer.c file | annotate | diff | comparison | revisions
src/cx/allocator.h file | annotate | diff | comparison | revisions
src/cx/buffer.h file | annotate | diff | comparison | revisions
src/cx/iterator.h file | annotate | diff | comparison | revisions
src/cx/linked_list.h file | annotate | diff | comparison | revisions
src/cx/list.h file | annotate | diff | comparison | revisions
src/linked_list.c file | annotate | diff | comparison | revisions
test/test_list.c file | annotate | diff | comparison | revisions
test/util_allocator.c file | annotate | diff | comparison | revisions
test/util_allocator.h file | annotate | diff | comparison | revisions
     1.1 --- a/src/allocator.c	Sat Jan 29 14:32:04 2022 +0100
     1.2 +++ b/src/allocator.c	Sun Jan 30 14:19:00 2022 +0100
     1.3 @@ -61,19 +61,30 @@
     1.4          &cx_default_allocator_class,
     1.5          NULL
     1.6  };
     1.7 -CxAllocator cxDefaultAllocator = &cx_default_allocator;
     1.8 +CxAllocator *cxDefaultAllocator = &cx_default_allocator;
     1.9  
    1.10  /* IMPLEMENTATION OF HIGH LEVEL API */
    1.11  
    1.12 -void *cxMalloc(CxAllocator allocator, size_t n) {
    1.13 +void *cxMalloc(
    1.14 +        CxAllocator *allocator,
    1.15 +        size_t n
    1.16 +) {
    1.17      return allocator->cl->malloc(allocator->data, n);
    1.18  }
    1.19  
    1.20 -void *cxRealloc(CxAllocator allocator, void *mem, size_t n) {
    1.21 +void *cxRealloc(
    1.22 +        CxAllocator *allocator,
    1.23 +        void *mem,
    1.24 +        size_t n
    1.25 +) {
    1.26      return allocator->cl->realloc(allocator->data, mem, n);
    1.27  }
    1.28  
    1.29 -int cxReallocate(CxAllocator allocator, void **mem, size_t n) {
    1.30 +int cxReallocate(
    1.31 +        CxAllocator *allocator,
    1.32 +        void **mem,
    1.33 +        size_t n
    1.34 +) {
    1.35      void *nmem = allocator->cl->realloc(allocator->data, *mem, n);
    1.36      if (nmem == NULL) {
    1.37          return 1;
    1.38 @@ -83,10 +94,17 @@
    1.39      }
    1.40  }
    1.41  
    1.42 -void *cxCalloc(CxAllocator allocator, size_t nelem, size_t n) {
    1.43 +void *cxCalloc(
    1.44 +        CxAllocator *allocator,
    1.45 +        size_t nelem,
    1.46 +        size_t n
    1.47 +) {
    1.48      return allocator->cl->calloc(allocator->data, nelem, n);
    1.49  }
    1.50  
    1.51 -void cxFree(CxAllocator allocator, void *mem) {
    1.52 +void cxFree(
    1.53 +        CxAllocator *allocator,
    1.54 +        void *mem
    1.55 +) {
    1.56      allocator->cl->free(allocator->data, mem);
    1.57  }
     2.1 --- a/src/buffer.c	Sat Jan 29 14:32:04 2022 +0100
     2.2 +++ b/src/buffer.c	Sun Jan 30 14:19:00 2022 +0100
     2.3 @@ -32,12 +32,12 @@
     2.4  #include <stdlib.h>
     2.5  #include <string.h>
     2.6  
     2.7 -CxBuffer cxBufferCreate(
     2.8 +CxBuffer *cxBufferCreate(
     2.9          void *space,
    2.10          size_t capacity,
    2.11          int flags
    2.12  ) {
    2.13 -    CxBuffer buffer = (CxBuffer) malloc(sizeof(cx_buffer_s));
    2.14 +    CxBuffer *buffer = (CxBuffer *) malloc(sizeof(cx_buffer_s));
    2.15      if (buffer) {
    2.16          buffer->flags = flags;
    2.17          if (!space) {
    2.18 @@ -60,15 +60,15 @@
    2.19      return buffer;
    2.20  }
    2.21  
    2.22 -void cxBufferDestroy(CxBuffer buffer) {
    2.23 +void cxBufferDestroy(CxBuffer *buffer) {
    2.24      if ((buffer->flags & CX_BUFFER_FREE_CONTENTS) == CX_BUFFER_FREE_CONTENTS) {
    2.25          free(buffer->bytes);
    2.26      }
    2.27      free(buffer);
    2.28  }
    2.29  
    2.30 -CxBuffer cxBufferExtract(
    2.31 -        CxBuffer src,
    2.32 +CxBuffer *cxBufferExtract(
    2.33 +        CxBuffer *src,
    2.34          size_t start,
    2.35          size_t length,
    2.36          int flags
    2.37 @@ -78,7 +78,7 @@
    2.38          return NULL;
    2.39      }
    2.40  
    2.41 -    CxBuffer dst = (CxBuffer) malloc(sizeof(cx_buffer_s));
    2.42 +    CxBuffer *dst = (CxBuffer *) malloc(sizeof(cx_buffer_s));
    2.43      if (dst) {
    2.44          dst->bytes = malloc(length);
    2.45          if (!dst->bytes) {
    2.46 @@ -95,7 +95,7 @@
    2.47  }
    2.48  
    2.49  int cxBufferSeek(
    2.50 -        CxBuffer buffer,
    2.51 +        CxBuffer *buffer,
    2.52          off_t offset,
    2.53          int whence
    2.54  ) {
    2.55 @@ -130,12 +130,12 @@
    2.56  
    2.57  }
    2.58  
    2.59 -int cxBufferEof(CxBuffer buffer) {
    2.60 +int cxBufferEof(CxBuffer *buffer) {
    2.61      return buffer->pos >= buffer->size;
    2.62  }
    2.63  
    2.64  int cxBufferMinimumCapacity(
    2.65 -        CxBuffer buffer,
    2.66 +        CxBuffer *buffer,
    2.67          size_t additional_bytes
    2.68  ) {
    2.69      size_t newcap = buffer->capacity + additional_bytes;
    2.70 @@ -161,7 +161,7 @@
    2.71          void const *ptr,
    2.72          size_t size,
    2.73          size_t nitems,
    2.74 -        CxBuffer buffer
    2.75 +        CxBuffer *buffer
    2.76  ) {
    2.77      size_t len;
    2.78      if (cx_szmul(size, nitems, &len)) {
    2.79 @@ -202,7 +202,7 @@
    2.80          void *ptr,
    2.81          size_t size,
    2.82          size_t nitems,
    2.83 -        CxBuffer buffer
    2.84 +        CxBuffer *buffer
    2.85  ) {
    2.86      size_t len;
    2.87      if (cx_szmul(size, nitems, &len)) {
    2.88 @@ -224,7 +224,7 @@
    2.89  }
    2.90  
    2.91  int cxBufferPut(
    2.92 -        CxBuffer buffer,
    2.93 +        CxBuffer *buffer,
    2.94          int c
    2.95  ) {
    2.96      if (buffer->pos >= buffer->capacity) {
    2.97 @@ -246,7 +246,7 @@
    2.98      return c;
    2.99  }
   2.100  
   2.101 -int cxBufferGet(CxBuffer buffer) {
   2.102 +int cxBufferGet(CxBuffer *buffer) {
   2.103      if (cxBufferEof(buffer)) {
   2.104          return EOF;
   2.105      } else {
   2.106 @@ -257,14 +257,14 @@
   2.107  }
   2.108  
   2.109  size_t cxBufferPutString(
   2.110 -        CxBuffer buffer,
   2.111 +        CxBuffer *buffer,
   2.112          const char *str
   2.113  ) {
   2.114      return cxBufferWrite(str, 1, strlen(str), buffer);
   2.115  }
   2.116  
   2.117  int cxBufferShiftLeft(
   2.118 -        CxBuffer buffer,
   2.119 +        CxBuffer *buffer,
   2.120          size_t shift
   2.121  ) {
   2.122      if (shift >= buffer->size) {
   2.123 @@ -283,7 +283,7 @@
   2.124  }
   2.125  
   2.126  int cxBufferShiftRight(
   2.127 -        CxBuffer buffer,
   2.128 +        CxBuffer *buffer,
   2.129          size_t shift
   2.130  ) {
   2.131      size_t req_capacity = buffer->size + shift;
   2.132 @@ -315,7 +315,7 @@
   2.133  }
   2.134  
   2.135  int cxBufferShift(
   2.136 -        CxBuffer buffer,
   2.137 +        CxBuffer *buffer,
   2.138          off_t shift
   2.139  ) {
   2.140      if (shift < 0) {
     3.1 --- a/src/cx/allocator.h	Sat Jan 29 14:32:04 2022 +0100
     3.2 +++ b/src/cx/allocator.h	Sun Jan 30 14:19:00 2022 +0100
     3.3 @@ -83,12 +83,12 @@
     3.4  /**
     3.5   * High-Level type alias for the allocator type.
     3.6   */
     3.7 -typedef struct cx_allocator_s *CxAllocator;
     3.8 +typedef struct cx_allocator_s CxAllocator;
     3.9  
    3.10  /**
    3.11   * A default allocator using standard library malloc() etc.
    3.12   */
    3.13 -extern CxAllocator cxDefaultAllocator;
    3.14 +extern CxAllocator *cxDefaultAllocator;
    3.15  
    3.16  /**
    3.17   * Allocate \p n bytes of memory.
    3.18 @@ -97,7 +97,10 @@
    3.19   * @param n the number of bytes
    3.20   * @return a pointer to the allocated memory
    3.21   */
    3.22 -void *cxMalloc(CxAllocator allocator, size_t n)
    3.23 +void *cxMalloc(
    3.24 +        CxAllocator *allocator,
    3.25 +        size_t n
    3.26 +)
    3.27  __attribute__((__malloc__))
    3.28  __attribute__((__alloc_size__(2)));
    3.29  
    3.30 @@ -113,7 +116,11 @@
    3.31   * @param n the new size in bytes
    3.32   * @return a pointer to the re-allocated memory
    3.33   */
    3.34 -void *cxRealloc(CxAllocator allocator, void *mem, size_t n)
    3.35 +void *cxRealloc(
    3.36 +        CxAllocator *allocator,
    3.37 +        void *mem,
    3.38 +        size_t n
    3.39 +)
    3.40  __attribute__((__warn_unused_result__))
    3.41  __attribute__((__alloc_size__(3)));
    3.42  
    3.43 @@ -132,7 +139,11 @@
    3.44   * @param n the new size in bytes
    3.45   * @return zero on success, non-zero on failure
    3.46   */
    3.47 -int cxReallocate(CxAllocator allocator, void **mem, size_t n)
    3.48 +int cxReallocate(
    3.49 +        CxAllocator *allocator,
    3.50 +        void **mem,
    3.51 +        size_t n
    3.52 +)
    3.53  __attribute__((__nonnull__));
    3.54  
    3.55  /**
    3.56 @@ -143,7 +154,11 @@
    3.57   * @param n the size of each element in bytes
    3.58   * @return a pointer to the allocated memory
    3.59   */
    3.60 -void *cxCalloc(CxAllocator allocator, size_t nelem, size_t n)
    3.61 +void *cxCalloc(
    3.62 +        CxAllocator *allocator,
    3.63 +        size_t nelem,
    3.64 +        size_t n
    3.65 +)
    3.66  __attribute__((__malloc__))
    3.67  __attribute__((__alloc_size__(2, 3)));
    3.68  
    3.69 @@ -155,7 +170,10 @@
    3.70   * @param allocator the allocator
    3.71   * @param mem a pointer to the block to free
    3.72   */
    3.73 -void cxFree(CxAllocator allocator, void *mem)
    3.74 +void cxFree(
    3.75 +        CxAllocator *allocator,
    3.76 +        void *mem
    3.77 +)
    3.78  __attribute__((__nonnull__));
    3.79  
    3.80  #ifdef __cplusplus
     4.1 --- a/src/cx/buffer.h	Sat Jan 29 14:32:04 2022 +0100
     4.2 +++ b/src/cx/buffer.h	Sun Jan 30 14:19:00 2022 +0100
     4.3 @@ -100,7 +100,7 @@
     4.4  /**
     4.5   * UCX buffer.
     4.6   */
     4.7 -typedef cx_buffer_s *CxBuffer;
     4.8 +typedef cx_buffer_s CxBuffer;
     4.9  
    4.10  /**
    4.11   * Creates a new buffer.
    4.12 @@ -115,7 +115,7 @@
    4.13   * @param flags buffer features (see cx_buffer_s.flags)
    4.14   * @return the new buffer
    4.15   */
    4.16 -CxBuffer cxBufferCreate(
    4.17 +CxBuffer *cxBufferCreate(
    4.18          void *space,
    4.19          size_t capacity,
    4.20          int flags
    4.21 @@ -129,7 +129,7 @@
    4.22   *
    4.23   * @param buffer the buffer to destroy
    4.24   */
    4.25 -void cxBufferDestroy(CxBuffer buffer);
    4.26 +void cxBufferDestroy(CxBuffer *buffer);
    4.27  
    4.28  /**
    4.29   * Creates a new buffer and fills it with content copied from another buffer.
    4.30 @@ -142,8 +142,8 @@
    4.31   * @param flags features for the new buffer (#CX_BUFFER_FREE_CONTENTS will always be enabled)
    4.32   * @return a new buffer containing the extraction
    4.33   */
    4.34 -CxBuffer cxBufferExtract(
    4.35 -        CxBuffer src,
    4.36 +CxBuffer *cxBufferExtract(
    4.37 +        CxBuffer *src,
    4.38          size_t start,
    4.39          size_t length,
    4.40          int flags
    4.41 @@ -193,7 +193,7 @@
    4.42   * @return 0 on success, non-zero if a required auto-extension fails
    4.43   */
    4.44  int cxBufferShift(
    4.45 -        CxBuffer buffer,
    4.46 +        CxBuffer *buffer,
    4.47          off_t shift
    4.48  );
    4.49  
    4.50 @@ -207,7 +207,7 @@
    4.51   * @see cxBufferShift()
    4.52   */
    4.53  int cxBufferShiftRight(
    4.54 -        CxBuffer buffer,
    4.55 +        CxBuffer *buffer,
    4.56          size_t shift
    4.57  );
    4.58  
    4.59 @@ -224,7 +224,7 @@
    4.60   * @see cxBufferShift()
    4.61   */
    4.62  int cxBufferShiftLeft(
    4.63 -        CxBuffer buffer,
    4.64 +        CxBuffer *buffer,
    4.65          size_t shift
    4.66  );
    4.67  
    4.68 @@ -249,7 +249,7 @@
    4.69   *
    4.70   */
    4.71  int cxBufferSeek(
    4.72 -        CxBuffer buffer,
    4.73 +        CxBuffer *buffer,
    4.74          off_t offset,
    4.75          int whence
    4.76  );
    4.77 @@ -271,7 +271,7 @@
    4.78   * @return non-zero, if the current buffer position has exceeded the last
    4.79   * available byte of the buffer.
    4.80   */
    4.81 -int cxBufferEof(CxBuffer buffer);
    4.82 +int cxBufferEof(CxBuffer *buffer);
    4.83  
    4.84  
    4.85  /**
    4.86 @@ -284,7 +284,7 @@
    4.87   * @return 0 on success or a non-zero value on failure
    4.88   */
    4.89  int cxBufferMinimumCapacity(
    4.90 -        CxBuffer buffer,
    4.91 +        CxBuffer *buffer,
    4.92          size_t capacity
    4.93  );
    4.94  
    4.95 @@ -305,7 +305,7 @@
    4.96          void const *ptr,
    4.97          size_t size,
    4.98          size_t nitems,
    4.99 -        CxBuffer buffer
   4.100 +        CxBuffer *buffer
   4.101  );
   4.102  
   4.103  /**
   4.104 @@ -325,7 +325,7 @@
   4.105          void *ptr,
   4.106          size_t size,
   4.107          size_t nitems,
   4.108 -        CxBuffer buffer
   4.109 +        CxBuffer *buffer
   4.110  );
   4.111  
   4.112  /**
   4.113 @@ -344,7 +344,7 @@
   4.114   * reached and automatic extension is not enabled or not possible
   4.115   */
   4.116  int cxBufferPut(
   4.117 -        CxBuffer buffer,
   4.118 +        CxBuffer *buffer,
   4.119          int c
   4.120  );
   4.121  
   4.122 @@ -356,7 +356,7 @@
   4.123   * @param buffer the buffer to read from
   4.124   * @return the character or \c EOF, if the end of the buffer is reached
   4.125   */
   4.126 -int cxBufferGet(CxBuffer buffer);
   4.127 +int cxBufferGet(CxBuffer *buffer);
   4.128  
   4.129  /**
   4.130   * Writes a string to a buffer.
   4.131 @@ -366,7 +366,7 @@
   4.132   * @return the number of bytes written
   4.133   */
   4.134  size_t cxBufferPutString(
   4.135 -        CxBuffer buffer,
   4.136 +        CxBuffer *buffer,
   4.137          const char *str
   4.138  );
   4.139  
     5.1 --- a/src/cx/iterator.h	Sat Jan 29 14:32:04 2022 +0100
     5.2 +++ b/src/cx/iterator.h	Sun Jan 30 14:19:00 2022 +0100
     5.3 @@ -40,36 +40,23 @@
     5.4  #include "common.h"
     5.5  
     5.6  /**
     5.7 - * Iterator value type.
     5.8 - * An iterator points to a certain element in an (possibly unbounded) chain of elements.
     5.9 - * Iterators that are based on collections (which have a defined "first" element), are supposed
    5.10 - * to be "position-aware", which means that they keep track of the current index within the collection.
    5.11 - *
    5.12 - * @note Objects that are pointed to by an iterator are mutable through that iterator. However, if the
    5.13 - * iterator is based on a collection and the underlying collection is mutated (elements added or removed),
    5.14 - * the iterator becomes invalid (regardless of what cxIteratorValid() returns) and MUST be re-obtained
    5.15 - * from the collection.
    5.16 - */
    5.17 -typedef struct cx_iterator_s CxIterator;
    5.18 -
    5.19 -/**
    5.20   * Internal iterator struct - use CxIterator.
    5.21   */
    5.22  struct cx_iterator_s {
    5.23      /**
    5.24       * True iff the iterator points to valid data.
    5.25       */
    5.26 -    bool (*valid)(CxIterator const *) __attribute__ ((__nonnull__));
    5.27 +    bool (*valid)(struct cx_iterator_s const *) __attribute__ ((__nonnull__));
    5.28  
    5.29      /**
    5.30       * Returns a pointer to the current element.
    5.31       */
    5.32 -    void *(*current)(CxIterator const *) __attribute__ ((__nonnull__));
    5.33 +    void *(*current)(struct cx_iterator_s const *) __attribute__ ((__nonnull__));
    5.34  
    5.35      /**
    5.36       * Advances the iterator.
    5.37       */
    5.38 -    void (*next)(CxIterator *) __attribute__ ((__nonnull__));
    5.39 +    void (*next)(struct cx_iterator_s *) __attribute__ ((__nonnull__));
    5.40  
    5.41      /**
    5.42       * Handle for the current element, if required.
    5.43 @@ -96,6 +83,19 @@
    5.44  };
    5.45  
    5.46  /**
    5.47 + * Iterator value type.
    5.48 + * An iterator points to a certain element in an (possibly unbounded) chain of elements.
    5.49 + * Iterators that are based on collections (which have a defined "first" element), are supposed
    5.50 + * to be "position-aware", which means that they keep track of the current index within the collection.
    5.51 + *
    5.52 + * @note Objects that are pointed to by an iterator are mutable through that iterator. However, if the
    5.53 + * iterator is based on a collection and the underlying collection is mutated (elements added or removed),
    5.54 + * the iterator becomes invalid (regardless of what cxIteratorValid() returns) and MUST be re-obtained
    5.55 + * from the collection.
    5.56 + */
    5.57 +typedef struct cx_iterator_s CxIterator;
    5.58 +
    5.59 +/**
    5.60   * Checks if the iterator points to valid data.
    5.61   *
    5.62   * This is especially false for past-the-end iterators.
     6.1 --- a/src/cx/linked_list.h	Sat Jan 29 14:32:04 2022 +0100
     6.2 +++ b/src/cx/linked_list.h	Sun Jan 30 14:19:00 2022 +0100
     6.3 @@ -55,8 +55,8 @@
     6.4   * @param item_size the size of each element in bytes
     6.5   * @return the created list
     6.6   */
     6.7 -CxList cxLinkedListCreate(
     6.8 -        CxAllocator allocator,
     6.9 +CxList *cxLinkedListCreate(
    6.10 +        CxAllocator *allocator,
    6.11          CxListComparator comparator,
    6.12          size_t item_size
    6.13  ) __attribute__((__nonnull__));
    6.14 @@ -70,8 +70,8 @@
    6.15   * @param comparator the comparator for the elements
    6.16   * @return the created list
    6.17   */
    6.18 -CxList cxPointerLinkedListCreate(
    6.19 -        CxAllocator allocator,
    6.20 +CxList *cxPointerLinkedListCreate(
    6.21 +        CxAllocator *allocator,
    6.22          CxListComparator comparator
    6.23  ) __attribute__((__nonnull__));
    6.24  
    6.25 @@ -85,8 +85,8 @@
    6.26   * @param array the array data
    6.27   * @return the created list
    6.28   */
    6.29 -CxList cxLinkedListFromArray(
    6.30 -        CxAllocator allocator,
    6.31 +CxList *cxLinkedListFromArray(
    6.32 +        CxAllocator *allocator,
    6.33          CxListComparator comparator,
    6.34          size_t item_size,
    6.35          size_t num_items,
    6.36 @@ -100,7 +100,7 @@
    6.37   *
    6.38   * @param list the list
    6.39   */
    6.40 -void cxLinkedListDestroy(CxList list) __attribute__((__nonnull__));
    6.41 +void cxLinkedListDestroy(CxList *list) __attribute__((__nonnull__));
    6.42  
    6.43  /**
    6.44   * Finds the node at a certain index.
     7.1 --- a/src/cx/list.h	Sat Jan 29 14:32:04 2022 +0100
     7.2 +++ b/src/cx/list.h	Sun Jan 30 14:19:00 2022 +0100
     7.3 @@ -54,90 +54,9 @@
     7.4  );
     7.5  
     7.6  /**
     7.7 - * Internal type for the list structure - use CxList instead.
     7.8 + * List class type.
     7.9   */
    7.10 -typedef struct cx_list_s cx_list_s;
    7.11 -
    7.12 -/**
    7.13 - * The class definition for arbitrary lists.
    7.14 - */
    7.15 -typedef struct {
    7.16 -    /**
    7.17 -     * Member function for adding an element.
    7.18 -     */
    7.19 -    int (*add)(
    7.20 -            cx_list_s *list,
    7.21 -            void const *elem
    7.22 -    );
    7.23 -
    7.24 -    /**
    7.25 -     * Member function for inserting an element.
    7.26 -     */
    7.27 -    int (*insert)(
    7.28 -            cx_list_s *list,
    7.29 -            size_t index,
    7.30 -            void const *elem
    7.31 -    );
    7.32 -
    7.33 -    /**
    7.34 -     * Member function for inserting an element relative to an iterator position.
    7.35 -     */
    7.36 -    int (*insert_iter)(
    7.37 -            CxIterator *iter,
    7.38 -            void const *elem,
    7.39 -            int prepend
    7.40 -    );
    7.41 -
    7.42 -    /**
    7.43 -     * Member function for removing an element.
    7.44 -     */
    7.45 -    int (*remove)(
    7.46 -            cx_list_s *list,
    7.47 -            size_t index
    7.48 -    );
    7.49 -
    7.50 -    /**
    7.51 -     * Member function for element lookup.
    7.52 -     */
    7.53 -    void *(*at)(
    7.54 -            cx_list_s const *list,
    7.55 -            size_t index
    7.56 -    );
    7.57 -
    7.58 -    /**
    7.59 -     * Member function for finding an element.
    7.60 -     */
    7.61 -    size_t (*find)(
    7.62 -            cx_list_s const *list,
    7.63 -            void const *elem
    7.64 -    );
    7.65 -
    7.66 -    /**
    7.67 -     * Member function for sorting the list in place.
    7.68 -     */
    7.69 -    void (*sort)(cx_list_s *list);
    7.70 -
    7.71 -    /**
    7.72 -     * Member function for comparing this list to another list of the same type.
    7.73 -     */
    7.74 -    int (*compare)(
    7.75 -            cx_list_s const *list,
    7.76 -            cx_list_s const *other
    7.77 -    );
    7.78 -
    7.79 -    /**
    7.80 -     * Member function for reversing the order of the items.
    7.81 -     */
    7.82 -    void (*reverse)(cx_list_s *list);
    7.83 -
    7.84 -    /**
    7.85 -     * Returns an iterator pointing to the specified index.
    7.86 -     */
    7.87 -    CxIterator (*iterator)(
    7.88 -            cx_list_s *list,
    7.89 -            size_t index
    7.90 -    );
    7.91 -} cx_list_class;
    7.92 +typedef struct cx_list_class_s cx_list_class;
    7.93  
    7.94  /**
    7.95   * Structure for holding the base data of a list.
    7.96 @@ -150,7 +69,7 @@
    7.97      /**
    7.98       * The allocator to use.
    7.99       */
   7.100 -    CxAllocator allocator;
   7.101 +    CxAllocator *allocator;
   7.102      /**
   7.103       * The comparator function for the elements.
   7.104       */
   7.105 @@ -170,9 +89,90 @@
   7.106  };
   7.107  
   7.108  /**
   7.109 + * The class definition for arbitrary lists.
   7.110 + */
   7.111 +struct cx_list_class_s {
   7.112 +    /**
   7.113 +     * Member function for adding an element.
   7.114 +     */
   7.115 +    int (*add)(
   7.116 +            struct cx_list_s *list,
   7.117 +            void const *elem
   7.118 +    );
   7.119 +
   7.120 +    /**
   7.121 +     * Member function for inserting an element.
   7.122 +     */
   7.123 +    int (*insert)(
   7.124 +            struct cx_list_s *list,
   7.125 +            size_t index,
   7.126 +            void const *elem
   7.127 +    );
   7.128 +
   7.129 +    /**
   7.130 +     * Member function for inserting an element relative to an iterator position.
   7.131 +     */
   7.132 +    int (*insert_iter)(
   7.133 +            struct cx_iterator_s *iter,
   7.134 +            void const *elem,
   7.135 +            int prepend
   7.136 +    );
   7.137 +
   7.138 +    /**
   7.139 +     * Member function for removing an element.
   7.140 +     */
   7.141 +    int (*remove)(
   7.142 +            struct cx_list_s *list,
   7.143 +            size_t index
   7.144 +    );
   7.145 +
   7.146 +    /**
   7.147 +     * Member function for element lookup.
   7.148 +     */
   7.149 +    void *(*at)(
   7.150 +            struct cx_list_s const *list,
   7.151 +            size_t index
   7.152 +    );
   7.153 +
   7.154 +    /**
   7.155 +     * Member function for finding an element.
   7.156 +     */
   7.157 +    size_t (*find)(
   7.158 +            struct cx_list_s const *list,
   7.159 +            void const *elem
   7.160 +    );
   7.161 +
   7.162 +    /**
   7.163 +     * Member function for sorting the list in place.
   7.164 +     */
   7.165 +    void (*sort)(struct cx_list_s *list);
   7.166 +
   7.167 +    /**
   7.168 +     * Member function for comparing this list to another list of the same type.
   7.169 +     */
   7.170 +    int (*compare)(
   7.171 +            struct cx_list_s const *list,
   7.172 +            struct cx_list_s const *other
   7.173 +    );
   7.174 +
   7.175 +    /**
   7.176 +     * Member function for reversing the order of the items.
   7.177 +     */
   7.178 +    void (*reverse)(struct cx_list_s *list);
   7.179 +
   7.180 +    /**
   7.181 +     * Returns an iterator pointing to the specified index.
   7.182 +     */
   7.183 +    struct cx_iterator_s (*iterator)(
   7.184 +            struct cx_list_s *list,
   7.185 +            size_t index
   7.186 +    );
   7.187 +};
   7.188 +
   7.189 +/**
   7.190   * Common type for all list implementations.
   7.191   */
   7.192 -typedef cx_list_s *CxList;
   7.193 +typedef struct cx_list_s CxList;
   7.194  
   7.195  /**
   7.196   * Adds an item to the end of the list.
   7.197 @@ -182,7 +182,7 @@
   7.198   * @return zero on success, non-zero on memory allocation failure
   7.199   */
   7.200  static inline int cxListAdd(
   7.201 -        CxList list,
   7.202 +        CxList *list,
   7.203          void const *elem
   7.204  ) {
   7.205      return list->cl->add(list, elem);
   7.206 @@ -202,7 +202,7 @@
   7.207   * @see cxListInsertBefore()
   7.208   */
   7.209  static inline int cxListInsert(
   7.210 -        CxList list,
   7.211 +        CxList *list,
   7.212          size_t index,
   7.213          void const *elem
   7.214  ) {
   7.215 @@ -228,7 +228,7 @@
   7.216          CxIterator *iter,
   7.217          void const *elem
   7.218  ) {
   7.219 -    return ((cx_list_s *) iter->src_handle)->cl->insert_iter(iter, elem, 0);
   7.220 +    return ((struct cx_list_s *) iter->src_handle)->cl->insert_iter(iter, elem, 0);
   7.221  }
   7.222  
   7.223  /**
   7.224 @@ -250,7 +250,7 @@
   7.225          CxIterator *iter,
   7.226          void const *elem
   7.227  ) {
   7.228 -    return ((cx_list_s *) iter->src_handle)->cl->insert_iter(iter, elem, 1);
   7.229 +    return ((struct cx_list_s *) iter->src_handle)->cl->insert_iter(iter, elem, 1);
   7.230  }
   7.231  
   7.232  /**
   7.233 @@ -260,7 +260,7 @@
   7.234   * @return zero on success, non-zero if the index is out of bounds
   7.235   */
   7.236  static inline int cxListRemove(
   7.237 -        CxList list,
   7.238 +        CxList *list,
   7.239          size_t index
   7.240  ) {
   7.241      return list->cl->remove(list, index);
   7.242 @@ -274,7 +274,7 @@
   7.243   * @return a pointer to the element or \c NULL if the index is out of bounds
   7.244   */
   7.245  static inline void *cxListAt(
   7.246 -        CxList list,
   7.247 +        CxList *list,
   7.248          size_t index
   7.249  ) {
   7.250      return list->cl->at(list, index);
   7.251 @@ -292,7 +292,7 @@
   7.252   * @return a new iterator
   7.253   */
   7.254  static inline CxIterator cxListIterator(
   7.255 -        CxList list,
   7.256 +        CxList *list,
   7.257          size_t index
   7.258  ) {
   7.259      return list->cl->iterator(list, index);
   7.260 @@ -308,7 +308,7 @@
   7.261   * @param list the list
   7.262   * @return a new iterator
   7.263   */
   7.264 -static inline CxIterator cxListBegin(CxList list) {
   7.265 +static inline CxIterator cxListBegin(CxList *list) {
   7.266      return list->cl->iterator(list, 0);
   7.267  }
   7.268  
   7.269 @@ -322,7 +322,7 @@
   7.270   * @return the index of the element or \c (size+1) if the element is not found
   7.271   */
   7.272  static inline size_t cxListFind(
   7.273 -        CxList list,
   7.274 +        CxList *list,
   7.275          void const *elem
   7.276  ) {
   7.277      return list->cl->find(list, elem);
   7.278 @@ -335,7 +335,7 @@
   7.279   *
   7.280   * @param list the list
   7.281   */
   7.282 -static inline void cxListSort(CxList list) {
   7.283 +static inline void cxListSort(CxList *list) {
   7.284      list->cl->sort(list);
   7.285  }
   7.286  
   7.287 @@ -344,7 +344,7 @@
   7.288   *
   7.289   * @param list the list
   7.290   */
   7.291 -static inline void cxListReverse(CxList list) {
   7.292 +static inline void cxListReverse(CxList *list) {
   7.293      list->cl->reverse(list);
   7.294  }
   7.295  
   7.296 @@ -358,8 +358,8 @@
   7.297   * @return zero, if both lists are equal element wise, negative if the first list is smaller, zero if the first list is larger
   7.298   */
   7.299  static inline int cxListCompare(
   7.300 -        CxList list,
   7.301 -        CxList other
   7.302 +        CxList *list,
   7.303 +        CxList *other
   7.304  ) {
   7.305      return list->cl->compare(list, other);
   7.306  }
     8.1 --- a/src/linked_list.c	Sat Jan 29 14:32:04 2022 +0100
     8.2 +++ b/src/linked_list.c	Sun Jan 30 14:19:00 2022 +0100
     8.3 @@ -463,7 +463,7 @@
     8.4  #define CX_LL_LOC_DATA offsetof(cx_linked_list_node, payload)
     8.5  
     8.6  typedef struct {
     8.7 -    cx_list_s base;
     8.8 +    struct cx_list_s base;
     8.9      cx_linked_list_node *begin;
    8.10      cx_linked_list_node *end;
    8.11  } cx_linked_list;
    8.12 @@ -482,7 +482,7 @@
    8.13  }
    8.14  
    8.15  static int cx_ll_insert_at(
    8.16 -        cx_list_s *list,
    8.17 +        struct cx_list_s *list,
    8.18          cx_linked_list_node *node,
    8.19          void const *elem
    8.20  ) {
    8.21 @@ -512,7 +512,7 @@
    8.22  }
    8.23  
    8.24  static int cx_ll_insert(
    8.25 -        cx_list_s *list,
    8.26 +        struct cx_list_s *list,
    8.27          size_t index,
    8.28          void const *elem
    8.29  ) {
    8.30 @@ -527,14 +527,14 @@
    8.31  }
    8.32  
    8.33  static int cx_ll_add(
    8.34 -        cx_list_s *list,
    8.35 +        struct cx_list_s *list,
    8.36          void const *elem
    8.37  ) {
    8.38      return cx_ll_insert(list, list->size, elem);
    8.39  }
    8.40  
    8.41  static int cx_pll_insert(
    8.42 -        cx_list_s *list,
    8.43 +        struct cx_list_s *list,
    8.44          size_t index,
    8.45          void const *elem
    8.46  ) {
    8.47 @@ -542,14 +542,14 @@
    8.48  }
    8.49  
    8.50  static int cx_pll_add(
    8.51 -        cx_list_s *list,
    8.52 +        struct cx_list_s *list,
    8.53          void const *elem
    8.54  ) {
    8.55      return cx_ll_insert(list, list->size, &elem);
    8.56  }
    8.57  
    8.58  static int cx_ll_remove(
    8.59 -        cx_list_s *list,
    8.60 +        struct cx_list_s *list,
    8.61          size_t index
    8.62  ) {
    8.63      cx_linked_list *ll = (cx_linked_list *) list;
    8.64 @@ -572,7 +572,7 @@
    8.65  }
    8.66  
    8.67  static void *cx_ll_at(
    8.68 -        cx_list_s const *list,
    8.69 +        struct cx_list_s const *list,
    8.70          size_t index
    8.71  ) {
    8.72      cx_linked_list *ll = (cx_linked_list *) list;
    8.73 @@ -581,7 +581,7 @@
    8.74  }
    8.75  
    8.76  static void *cx_pll_at(
    8.77 -        cx_list_s const *list,
    8.78 +        struct cx_list_s const *list,
    8.79          size_t index
    8.80  ) {
    8.81      cx_linked_list *ll = (cx_linked_list *) list;
    8.82 @@ -590,7 +590,7 @@
    8.83  }
    8.84  
    8.85  static size_t cx_ll_find(
    8.86 -        cx_list_s const *list,
    8.87 +        struct cx_list_s const *list,
    8.88          void const *elem
    8.89  ) {
    8.90      return cx_linked_list_find(((cx_linked_list *) list)->begin,
    8.91 @@ -599,7 +599,7 @@
    8.92  }
    8.93  
    8.94  static size_t cx_pll_find(
    8.95 -        cx_list_s const *list,
    8.96 +        struct cx_list_s const *list,
    8.97          void const *elem
    8.98  ) {
    8.99      return cx_linked_list_find(((cx_linked_list *) list)->begin,
   8.100 @@ -607,28 +607,28 @@
   8.101                                 true, list->cmpfunc, elem);
   8.102  }
   8.103  
   8.104 -static void cx_ll_sort(cx_list_s *list) {
   8.105 +static void cx_ll_sort(struct cx_list_s *list) {
   8.106      cx_linked_list *ll = (cx_linked_list *) list;
   8.107      cx_linked_list_sort((void **) &ll->begin, (void **) &ll->end,
   8.108                          CX_LL_LOC_PREV, CX_LL_LOC_NEXT, CX_LL_LOC_DATA,
   8.109                          false, list->cmpfunc);
   8.110  }
   8.111  
   8.112 -static void cx_pll_sort(cx_list_s *list) {
   8.113 +static void cx_pll_sort(struct cx_list_s *list) {
   8.114      cx_linked_list *ll = (cx_linked_list *) list;
   8.115      cx_linked_list_sort((void **) &ll->begin, (void **) &ll->end,
   8.116                          CX_LL_LOC_PREV, CX_LL_LOC_NEXT, CX_LL_LOC_DATA,
   8.117                          true, list->cmpfunc);
   8.118  }
   8.119  
   8.120 -static void cx_ll_reverse(cx_list_s *list) {
   8.121 +static void cx_ll_reverse(struct cx_list_s *list) {
   8.122      cx_linked_list *ll = (cx_linked_list *) list;
   8.123      cx_linked_list_reverse((void **) &ll->begin, (void **) ll->end, CX_LL_LOC_PREV, CX_LL_LOC_NEXT);
   8.124  }
   8.125  
   8.126  static int cx_ll_compare(
   8.127 -        cx_list_s const *list,
   8.128 -        cx_list_s const *other
   8.129 +        struct cx_list_s const *list,
   8.130 +        struct cx_list_s const *other
   8.131  ) {
   8.132      cx_linked_list *left = (cx_linked_list *) list;
   8.133      cx_linked_list *right = (cx_linked_list *) other;
   8.134 @@ -638,8 +638,8 @@
   8.135  }
   8.136  
   8.137  static int cx_pll_compare(
   8.138 -        cx_list_s const *list,
   8.139 -        cx_list_s const *other
   8.140 +        struct cx_list_s const *list,
   8.141 +        struct cx_list_s const *other
   8.142  ) {
   8.143      cx_linked_list *left = (cx_linked_list *) list;
   8.144      cx_linked_list *right = (cx_linked_list *) other;
   8.145 @@ -680,7 +680,7 @@
   8.146  }
   8.147  
   8.148  static CxIterator cx_ll_iterator(
   8.149 -        cx_list_s *list,
   8.150 +        struct cx_list_s *list,
   8.151          size_t index
   8.152  ) {
   8.153      CxIterator iter;
   8.154 @@ -695,7 +695,7 @@
   8.155  }
   8.156  
   8.157  static CxIterator cx_pll_iterator(
   8.158 -        cx_list_s *list,
   8.159 +        struct cx_list_s *list,
   8.160          size_t index
   8.161  ) {
   8.162      CxIterator iter = cx_ll_iterator(list, index);
   8.163 @@ -708,7 +708,7 @@
   8.164          void const *elem,
   8.165          int prepend
   8.166  ) {
   8.167 -    cx_list_s *list = iter->src_handle;
   8.168 +    struct cx_list_s *list = iter->src_handle;
   8.169      cx_linked_list_node *node = iter->elem_handle;
   8.170      if (node != NULL) {
   8.171          assert(prepend >= 0 && prepend <= 1);
   8.172 @@ -757,8 +757,8 @@
   8.173          cx_pll_iterator,
   8.174  };
   8.175  
   8.176 -CxList cxLinkedListCreate(
   8.177 -        CxAllocator allocator,
   8.178 +CxList *cxLinkedListCreate(
   8.179 +        CxAllocator *allocator,
   8.180          CxListComparator comparator,
   8.181          size_t item_size
   8.182  ) {
   8.183 @@ -776,11 +776,11 @@
   8.184      list->begin = NULL;
   8.185      list->end = NULL;
   8.186  
   8.187 -    return (CxList) list;
   8.188 +    return (CxList *) list;
   8.189  }
   8.190  
   8.191 -CxList cxPointerLinkedListCreate(
   8.192 -        CxAllocator allocator,
   8.193 +CxList *cxPointerLinkedListCreate(
   8.194 +        CxAllocator *allocator,
   8.195          CxListComparator comparator
   8.196  ) {
   8.197      cx_linked_list *list = cxMalloc(allocator, sizeof(cx_linked_list));
   8.198 @@ -797,17 +797,17 @@
   8.199      list->begin = NULL;
   8.200      list->end = NULL;
   8.201  
   8.202 -    return (CxList) list;
   8.203 +    return (CxList *) list;
   8.204  }
   8.205  
   8.206 -CxList cxLinkedListFromArray(
   8.207 -        CxAllocator allocator,
   8.208 +CxList *cxLinkedListFromArray(
   8.209 +        CxAllocator *allocator,
   8.210          CxListComparator comparator,
   8.211          size_t item_size,
   8.212          size_t num_items,
   8.213          void const *array
   8.214  ) {
   8.215 -    CxList list = cxLinkedListCreate(allocator, comparator, item_size);
   8.216 +    CxList *list = cxLinkedListCreate(allocator, comparator, item_size);
   8.217      if (list == NULL) return NULL;
   8.218      for (size_t i = 0; i < num_items; i++) {
   8.219          if (0 != cxListAdd(list, ((const unsigned char *) array) + i * item_size)) {
   8.220 @@ -818,7 +818,7 @@
   8.221      return list;
   8.222  }
   8.223  
   8.224 -void cxLinkedListDestroy(CxList list) {
   8.225 +void cxLinkedListDestroy(CxList *list) {
   8.226      cx_linked_list *ll = (cx_linked_list *) list;
   8.227  
   8.228      cx_linked_list_node *node = ll->begin;
     9.1 --- a/test/test_list.c	Sat Jan 29 14:32:04 2022 +0100
     9.2 +++ b/test/test_list.c	Sun Jan 30 14:19:00 2022 +0100
     9.3 @@ -560,7 +560,7 @@
     9.4  void test_hl_linked_list_create(void) {
     9.5      cxTestingAllocatorReset();
     9.6  
     9.7 -    CxList list = cxLinkedListCreate(cxTestingAllocator, cmp_int, sizeof(int));
     9.8 +    CxList *list = cxLinkedListCreate(cxTestingAllocator, cmp_int, sizeof(int));
     9.9  
    9.10      CU_ASSERT_EQUAL(list->size, 0)
    9.11      CU_ASSERT_EQUAL(list->capacity, (size_t) -1)
    9.12 @@ -575,7 +575,7 @@
    9.13  void test_hl_ptr_linked_list_create(void) {
    9.14      cxTestingAllocatorReset();
    9.15  
    9.16 -    CxList list = cxPointerLinkedListCreate(cxTestingAllocator, cmp_int);
    9.17 +    CxList *list = cxPointerLinkedListCreate(cxTestingAllocator, cmp_int);
    9.18  
    9.19      CU_ASSERT_EQUAL(list->size, 0)
    9.20      CU_ASSERT_EQUAL(list->capacity, (size_t) -1)
    9.21 @@ -592,10 +592,10 @@
    9.22  
    9.23      int data[] = {2, 4, 5, 7, 10, 15};
    9.24  
    9.25 -    CxList expected = cxLinkedListCreate(cxTestingAllocator, cmp_int, sizeof(int));
    9.26 +    CxList *expected = cxLinkedListCreate(cxTestingAllocator, cmp_int, sizeof(int));
    9.27      for (int i = 0; i < 5; i++) cxListAdd(expected, &data[i]);
    9.28  
    9.29 -    CxList list = cxLinkedListFromArray(cxTestingAllocator, cmp_int, sizeof(int), 5, data);
    9.30 +    CxList *list = cxLinkedListFromArray(cxTestingAllocator, cmp_int, sizeof(int), 5, data);
    9.31  
    9.32      CU_ASSERT_TRUE(0 == cxListCompare(list, expected))
    9.33  
    9.34 @@ -608,7 +608,7 @@
    9.35      cxTestingAllocatorReset();
    9.36  
    9.37      int data;
    9.38 -    CxList list = cxLinkedListCreate(cxTestingAllocator, cmp_int, sizeof(int));
    9.39 +    CxList *list = cxLinkedListCreate(cxTestingAllocator, cmp_int, sizeof(int));
    9.40  
    9.41      data = 5;
    9.42      CU_ASSERT_EQUAL(cxListAdd(list, &data), 0)
    9.43 @@ -621,7 +621,7 @@
    9.44      CU_ASSERT_TRUE(list->capacity >= list->size)
    9.45  
    9.46      int exp[] = {5, 47, 13};
    9.47 -    CxList expected = cxLinkedListFromArray(cxTestingAllocator, cmp_int, sizeof(int), 3, exp);
    9.48 +    CxList *expected = cxLinkedListFromArray(cxTestingAllocator, cmp_int, sizeof(int), 3, exp);
    9.49      CU_ASSERT_TRUE(0 == cxListCompare(list, expected))
    9.50  
    9.51      cxLinkedListDestroy(list);
    9.52 @@ -632,7 +632,7 @@
    9.53  void test_hl_ptr_linked_list_add(void) {
    9.54      cxTestingAllocatorReset();
    9.55  
    9.56 -    CxList list = cxPointerLinkedListCreate(cxTestingAllocator, cmp_int);
    9.57 +    CxList *list = cxPointerLinkedListCreate(cxTestingAllocator, cmp_int);
    9.58  
    9.59      int a = 5, b = 47, c = 13;
    9.60  
    9.61 @@ -663,7 +663,7 @@
    9.62      cxTestingAllocatorReset();
    9.63  
    9.64      int data;
    9.65 -    CxList list = cxLinkedListCreate(cxTestingAllocator, cmp_int, sizeof(int));
    9.66 +    CxList *list = cxLinkedListCreate(cxTestingAllocator, cmp_int, sizeof(int));
    9.67  
    9.68      data = 5;
    9.69      CU_ASSERT_NOT_EQUAL(cxListInsert(list, 1, &data), 0)
    9.70 @@ -683,7 +683,7 @@
    9.71      CU_ASSERT_TRUE(list->capacity >= list->size)
    9.72  
    9.73      int exp[] = {47, 13, 5, 42};
    9.74 -    CxList expected = cxLinkedListFromArray(cxTestingAllocator, cmp_int, sizeof(int), 4, exp);
    9.75 +    CxList *expected = cxLinkedListFromArray(cxTestingAllocator, cmp_int, sizeof(int), 4, exp);
    9.76      CU_ASSERT_TRUE(0 == cxListCompare(list, expected))
    9.77  
    9.78      cxLinkedListDestroy(list);
    9.79 @@ -694,7 +694,7 @@
    9.80  void test_hl_ptr_linked_list_insert(void) {
    9.81      cxTestingAllocatorReset();
    9.82  
    9.83 -    CxList list = cxPointerLinkedListCreate(cxTestingAllocator, cmp_int);
    9.84 +    CxList *list = cxPointerLinkedListCreate(cxTestingAllocator, cmp_int);
    9.85  
    9.86      int a = 5, b = 47, c = 13, d = 42;
    9.87  
    9.88 @@ -724,8 +724,8 @@
    9.89      cxTestingAllocatorReset();
    9.90  
    9.91      int data[] = {5, 47, 42, 13};
    9.92 -    CxList list = cxLinkedListFromArray(cxTestingAllocator, cmp_int,
    9.93 -                                        sizeof(int), 4, data);
    9.94 +    CxList *list = cxLinkedListFromArray(cxTestingAllocator, cmp_int,
    9.95 +                                         sizeof(int), 4, data);
    9.96  
    9.97      CU_ASSERT_EQUAL(list->size, 4)
    9.98      CU_ASSERT_TRUE(list->capacity >= list->size)
    9.99 @@ -764,7 +764,7 @@
   9.100      cxTestingAllocatorReset();
   9.101  
   9.102      int a = 5, b = 47, c = 42, d = 13;
   9.103 -    CxList list = cxPointerLinkedListCreate(cxTestingAllocator, cmp_int);
   9.104 +    CxList *list = cxPointerLinkedListCreate(cxTestingAllocator, cmp_int);
   9.105  
   9.106      cxListAdd(list, &a);
   9.107      cxListAdd(list, &b);
   9.108 @@ -808,8 +808,8 @@
   9.109      cxTestingAllocatorReset();
   9.110  
   9.111      int data[] = {5, 47, 13};
   9.112 -    CxList list = cxLinkedListFromArray(cxTestingAllocator, cmp_int,
   9.113 -                                        sizeof(int), 3, data);
   9.114 +    CxList *list = cxLinkedListFromArray(cxTestingAllocator, cmp_int,
   9.115 +                                         sizeof(int), 3, data);
   9.116  
   9.117      CU_ASSERT_EQUAL(*(int *) cxListAt(list, 0), 5)
   9.118      CU_ASSERT_EQUAL(*(int *) cxListAt(list, 1), 47)
   9.119 @@ -823,7 +823,7 @@
   9.120  void test_hl_ptr_linked_list_at(void) {
   9.121      cxTestingAllocatorReset();
   9.122  
   9.123 -    CxList list = cxPointerLinkedListCreate(cxTestingAllocator, cmp_int);
   9.124 +    CxList *list = cxPointerLinkedListCreate(cxTestingAllocator, cmp_int);
   9.125  
   9.126      int a = 5, b = 47, c = 13;
   9.127      cxListAdd(list, &a);
   9.128 @@ -843,8 +843,8 @@
   9.129      cxTestingAllocatorReset();
   9.130  
   9.131      int data[] = {5, 47, 13};
   9.132 -    CxList list = cxLinkedListFromArray(cxTestingAllocator, cmp_int,
   9.133 -                                        sizeof(int), 3, data);
   9.134 +    CxList *list = cxLinkedListFromArray(cxTestingAllocator, cmp_int,
   9.135 +                                         sizeof(int), 3, data);
   9.136      CU_ASSERT_EQUAL(list->size, 3)
   9.137      CU_ASSERT_TRUE(list->capacity >= list->size)
   9.138  
   9.139 @@ -869,7 +869,7 @@
   9.140      cxTestingAllocatorReset();
   9.141  
   9.142      int a = 5, b = 47, c = 13, criteria;
   9.143 -    CxList list = cxPointerLinkedListCreate(cxTestingAllocator, cmp_int);
   9.144 +    CxList *list = cxPointerLinkedListCreate(cxTestingAllocator, cmp_int);
   9.145  
   9.146      cxListAdd(list, &a);
   9.147      cxListAdd(list, &b);
   9.148 @@ -915,8 +915,8 @@
   9.149  
   9.150      cxTestingAllocatorReset();
   9.151  
   9.152 -    CxList list = cxLinkedListFromArray(cxTestingAllocator, cmp_int, sizeof(int), 100, scrambled);
   9.153 -    CxList exp = cxLinkedListFromArray(cxTestingAllocator, cmp_int, sizeof(int), 100, expected);
   9.154 +    CxList *list = cxLinkedListFromArray(cxTestingAllocator, cmp_int, sizeof(int), 100, scrambled);
   9.155 +    CxList *exp = cxLinkedListFromArray(cxTestingAllocator, cmp_int, sizeof(int), 100, expected);
   9.156  
   9.157      cxListSort(list);
   9.158      CU_ASSERT_TRUE(0 == cxListCompare(list, exp))
   9.159 @@ -946,7 +946,7 @@
   9.160  
   9.161      cxTestingAllocatorReset();
   9.162  
   9.163 -    CxList list = cxPointerLinkedListCreate(cxTestingAllocator, cmp_int);
   9.164 +    CxList *list = cxPointerLinkedListCreate(cxTestingAllocator, cmp_int);
   9.165  
   9.166      for (int i = 0; i < 100; i++) {
   9.167          cxListAdd(list, &scrambled[i]);
   9.168 @@ -962,7 +962,7 @@
   9.169      CU_ASSERT_TRUE(cxTestingAllocatorVerify())
   9.170  }
   9.171  
   9.172 -void test_hl_linked_list_iterator_impl(CxList list) {
   9.173 +void test_hl_linked_list_iterator_impl(CxList *list) {
   9.174      int i = 0;
   9.175      CxIterator iter = cxListBegin(list);
   9.176      cx_foreach(int*, x, iter) {
   9.177 @@ -984,7 +984,7 @@
   9.178  
   9.179  void test_hl_linked_list_iterator(void) {
   9.180      cxTestingAllocatorReset();
   9.181 -    CxList list = cxLinkedListCreate(cxTestingAllocator, cmp_int, sizeof(int));
   9.182 +    CxList *list = cxLinkedListCreate(cxTestingAllocator, cmp_int, sizeof(int));
   9.183      for (int i = 0; i < 10; i++) {
   9.184          cxListAdd(list, &i);
   9.185      }
   9.186 @@ -993,7 +993,7 @@
   9.187  
   9.188  void test_hl_ptr_linked_list_iterator(void) {
   9.189      cxTestingAllocatorReset();
   9.190 -    CxList list = cxPointerLinkedListCreate(cxTestingAllocator, cmp_int);
   9.191 +    CxList *list = cxPointerLinkedListCreate(cxTestingAllocator, cmp_int);
   9.192      int data[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
   9.193      for (int i = 0; i < 10; i++) {
   9.194          cxListAdd(list, &data[i]);
   9.195 @@ -1003,7 +1003,7 @@
   9.196  
   9.197  void test_hl_linked_list_insert_via_iterator(void) {
   9.198      cxTestingAllocatorReset();
   9.199 -    CxList list = cxLinkedListCreate(cxTestingAllocator, cmp_int, sizeof(int));
   9.200 +    CxList *list = cxLinkedListCreate(cxTestingAllocator, cmp_int, sizeof(int));
   9.201      for (int i = 0; i < 5; i++) {
   9.202          cxListAdd(list, &i);
   9.203      }
   9.204 @@ -1037,8 +1037,8 @@
   9.205      CU_ASSERT_FALSE(cxIteratorValid(&iter))
   9.206  
   9.207      int expdata[] = {30, 0, 1, 20, 2, 10, 3, 4, 40, 50};
   9.208 -    CxList expected = cxLinkedListFromArray(cxTestingAllocator,
   9.209 -                                            cmp_int, sizeof(int), 10, expdata);
   9.210 +    CxList *expected = cxLinkedListFromArray(cxTestingAllocator,
   9.211 +                                             cmp_int, sizeof(int), 10, expdata);
   9.212  
   9.213      CU_ASSERT_EQUAL(0, cxListCompare(list, expected))
   9.214      cxLinkedListDestroy(list);
   9.215 @@ -1049,7 +1049,7 @@
   9.216  void test_hl_ptr_linked_list_insert_via_iterator(void) {
   9.217      int testdata[] = {0, 1, 2, 3, 4, 10, 20, 30, 40, 50};
   9.218      cxTestingAllocatorReset();
   9.219 -    CxList list = cxPointerLinkedListCreate(cxTestingAllocator, cmp_int);
   9.220 +    CxList *list = cxPointerLinkedListCreate(cxTestingAllocator, cmp_int);
   9.221      int i;
   9.222      for (i = 0; i < 5; i++) {
   9.223          cxListAdd(list, &testdata[i]);
    10.1 --- a/test/util_allocator.c	Sat Jan 29 14:32:04 2022 +0100
    10.2 +++ b/test/util_allocator.c	Sun Jan 30 14:19:00 2022 +0100
    10.3 @@ -113,7 +113,7 @@
    10.4          &cx_testing_allocator_class,
    10.5          &cx_testing_allocator_data
    10.6  };
    10.7 -CxAllocator cxTestingAllocator = &cx_testing_allocator;
    10.8 +CxAllocator *cxTestingAllocator = &cx_testing_allocator;
    10.9  
   10.10  void cxTestingAllocatorReset(void) {
   10.11      memset(&cx_testing_allocator_data, 0, sizeof(cx_testing_allocator_s));
    11.1 --- a/test/util_allocator.h	Sat Jan 29 14:32:04 2022 +0100
    11.2 +++ b/test/util_allocator.h	Sun Jan 30 14:19:00 2022 +0100
    11.3 @@ -68,7 +68,7 @@
    11.4      void *tracked[CX_TESTING_ALLOCATOR_MAX_LIVE];
    11.5  } cx_testing_allocator_s;
    11.6  
    11.7 -extern CxAllocator cxTestingAllocator;
    11.8 +extern CxAllocator *cxTestingAllocator;
    11.9  
   11.10  /**
   11.11   * Resets the testing allocator information.

mercurial