make allocator in cxBufferInit optional

Mon, 03 Apr 2023 19:09:31 +0200

author
Mike Becker <universe@uap-core.de>
date
Mon, 03 Apr 2023 19:09:31 +0200
changeset 673
60fb6aec157d
parent 672
55d8fdd38ca4
child 674
dc514a5d42a5

make allocator in cxBufferInit optional

src/buffer.c file | annotate | diff | comparison | revisions
src/cx/buffer.h file | annotate | diff | comparison | revisions
     1.1 --- a/src/buffer.c	Sat Apr 01 11:51:48 2023 +0200
     1.2 +++ b/src/buffer.c	Mon Apr 03 19:09:31 2023 +0200
     1.3 @@ -39,6 +39,7 @@
     1.4          CxAllocator const *allocator,
     1.5          int flags
     1.6  ) {
     1.7 +    if (allocator == NULL) allocator = cxDefaultAllocator;
     1.8      buffer->allocator = allocator;
     1.9      buffer->flags = flags;
    1.10      if (!space) {
     2.1 --- a/src/cx/buffer.h	Sat Apr 01 11:51:48 2023 +0200
     2.2 +++ b/src/cx/buffer.h	Mon Apr 03 19:09:31 2023 +0200
     2.3 @@ -149,11 +149,12 @@
     2.4   * @param space pointer to the memory area, or \c NULL to allocate
     2.5   * new memory
     2.6   * @param capacity the capacity of the buffer
     2.7 - * @param allocator the allocator this buffer shall use for automatic memory management
     2.8 + * @param allocator the allocator this buffer shall use for automatic
     2.9 + * memory management. If \c NULL, the default heap allocator will be used.
    2.10   * @param flags buffer features (see cx_buffer_s.flags)
    2.11   * @return zero on success, non-zero if a required allocation failed
    2.12   */
    2.13 -__attribute__((__nonnull__(1, 4)))
    2.14 +__attribute__((__nonnull__(1)))
    2.15  int cxBufferInit(
    2.16          CxBuffer *buffer,
    2.17          void *space,

mercurial