Thu, 30 Oct 2025 19:27:18 +0100
fix typo bug in cxListDifference() - resolves #745
| 391 
f094a53c1178
adds allocator interface and default implementation
 Mike Becker <universe@uap-core.de> parents: diff
changeset | 1 | /* | 
| 
f094a53c1178
adds allocator interface and default implementation
 Mike Becker <universe@uap-core.de> parents: diff
changeset | 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | 
| 
f094a53c1178
adds allocator interface and default implementation
 Mike Becker <universe@uap-core.de> parents: diff
changeset | 3 | * | 
| 
f094a53c1178
adds allocator interface and default implementation
 Mike Becker <universe@uap-core.de> parents: diff
changeset | 4 | * Copyright 2021 Mike Becker, Olaf Wintermann All rights reserved. | 
| 
f094a53c1178
adds allocator interface and default implementation
 Mike Becker <universe@uap-core.de> parents: diff
changeset | 5 | * | 
| 
f094a53c1178
adds allocator interface and default implementation
 Mike Becker <universe@uap-core.de> parents: diff
changeset | 6 | * Redistribution and use in source and binary forms, with or without | 
| 
f094a53c1178
adds allocator interface and default implementation
 Mike Becker <universe@uap-core.de> parents: diff
changeset | 7 | * modification, are permitted provided that the following conditions are met: | 
| 
f094a53c1178
adds allocator interface and default implementation
 Mike Becker <universe@uap-core.de> parents: diff
changeset | 8 | * | 
| 
f094a53c1178
adds allocator interface and default implementation
 Mike Becker <universe@uap-core.de> parents: diff
changeset | 9 | * 1. Redistributions of source code must retain the above copyright | 
| 
f094a53c1178
adds allocator interface and default implementation
 Mike Becker <universe@uap-core.de> parents: diff
changeset | 10 | * notice, this list of conditions and the following disclaimer. | 
| 
f094a53c1178
adds allocator interface and default implementation
 Mike Becker <universe@uap-core.de> parents: diff
changeset | 11 | * | 
| 
f094a53c1178
adds allocator interface and default implementation
 Mike Becker <universe@uap-core.de> parents: diff
changeset | 12 | * 2. Redistributions in binary form must reproduce the above copyright | 
| 
f094a53c1178
adds allocator interface and default implementation
 Mike Becker <universe@uap-core.de> parents: diff
changeset | 13 | * notice, this list of conditions and the following disclaimer in the | 
| 
f094a53c1178
adds allocator interface and default implementation
 Mike Becker <universe@uap-core.de> parents: diff
changeset | 14 | * documentation and/or other materials provided with the distribution. | 
| 
f094a53c1178
adds allocator interface and default implementation
 Mike Becker <universe@uap-core.de> parents: diff
changeset | 15 | * | 
| 
f094a53c1178
adds allocator interface and default implementation
 Mike Becker <universe@uap-core.de> parents: diff
changeset | 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | 
| 
f094a53c1178
adds allocator interface and default implementation
 Mike Becker <universe@uap-core.de> parents: diff
changeset | 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 
| 
f094a53c1178
adds allocator interface and default implementation
 Mike Becker <universe@uap-core.de> parents: diff
changeset | 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 
| 
f094a53c1178
adds allocator interface and default implementation
 Mike Becker <universe@uap-core.de> parents: diff
changeset | 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | 
| 
f094a53c1178
adds allocator interface and default implementation
 Mike Becker <universe@uap-core.de> parents: diff
changeset | 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 
| 
f094a53c1178
adds allocator interface and default implementation
 Mike Becker <universe@uap-core.de> parents: diff
changeset | 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 
| 
f094a53c1178
adds allocator interface and default implementation
 Mike Becker <universe@uap-core.de> parents: diff
changeset | 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 
| 
f094a53c1178
adds allocator interface and default implementation
 Mike Becker <universe@uap-core.de> parents: diff
changeset | 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 
| 
f094a53c1178
adds allocator interface and default implementation
 Mike Becker <universe@uap-core.de> parents: diff
changeset | 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 
| 
f094a53c1178
adds allocator interface and default implementation
 Mike Becker <universe@uap-core.de> parents: diff
changeset | 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 
| 
f094a53c1178
adds allocator interface and default implementation
 Mike Becker <universe@uap-core.de> parents: diff
changeset | 26 | * POSSIBILITY OF SUCH DAMAGE. | 
| 
f094a53c1178
adds allocator interface and default implementation
 Mike Becker <universe@uap-core.de> parents: diff
changeset | 27 | */ | 
| 429 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 28 | /** | 
| 1085 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 29 | * @file allocator.h | 
| 429 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 30 | * Interface for custom allocators. | 
| 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 31 | */ | 
| 391 
f094a53c1178
adds allocator interface and default implementation
 Mike Becker <universe@uap-core.de> parents: diff
changeset | 32 | |
| 
f094a53c1178
adds allocator interface and default implementation
 Mike Becker <universe@uap-core.de> parents: diff
changeset | 33 | #ifndef UCX_ALLOCATOR_H | 
| 
f094a53c1178
adds allocator interface and default implementation
 Mike Becker <universe@uap-core.de> parents: diff
changeset | 34 | #define UCX_ALLOCATOR_H | 
| 
f094a53c1178
adds allocator interface and default implementation
 Mike Becker <universe@uap-core.de> parents: diff
changeset | 35 | |
| 484 
9e6900b1cf9d
add common.h include to all other header files
 Mike Becker <universe@uap-core.de> parents: 
465diff
changeset | 36 | #include "common.h" | 
| 391 
f094a53c1178
adds allocator interface and default implementation
 Mike Becker <universe@uap-core.de> parents: diff
changeset | 37 | |
| 415 | 38 | #ifdef __cplusplus | 
| 39 | extern "C" { | |
| 40 | #endif | |
| 41 | ||
| 429 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 42 | /** | 
| 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 43 | * The class definition for an allocator. | 
| 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 44 | */ | 
| 396 
3539dd99ab92
make cx_allocator_class shared
 Mike Becker <universe@uap-core.de> parents: 
394diff
changeset | 45 | typedef struct { | 
| 429 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 46 | /** | 
| 465 
1e3cb39815f8
remove redundant documentation for function pointers
 Mike Becker <universe@uap-core.de> parents: 
461diff
changeset | 47 | * The allocator's malloc() implementation. | 
| 429 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 48 | */ | 
| 1426 
3a89b31f0724
clean up header files and adds support for comparing arbitrary strings with string.h functions
 Mike Becker <universe@uap-core.de> parents: 
1424diff
changeset | 49 | void *(*malloc)(void *data, size_t n); | 
| 429 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 50 | |
| 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 51 | /** | 
| 465 
1e3cb39815f8
remove redundant documentation for function pointers
 Mike Becker <universe@uap-core.de> parents: 
461diff
changeset | 52 | * The allocator's realloc() implementation. | 
| 429 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 53 | */ | 
| 1426 
3a89b31f0724
clean up header files and adds support for comparing arbitrary strings with string.h functions
 Mike Becker <universe@uap-core.de> parents: 
1424diff
changeset | 54 | void *(*realloc)(void *data, void *mem, size_t n); | 
| 429 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 55 | |
| 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 56 | /** | 
| 465 
1e3cb39815f8
remove redundant documentation for function pointers
 Mike Becker <universe@uap-core.de> parents: 
461diff
changeset | 57 | * The allocator's calloc() implementation. | 
| 429 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 58 | */ | 
| 1426 
3a89b31f0724
clean up header files and adds support for comparing arbitrary strings with string.h functions
 Mike Becker <universe@uap-core.de> parents: 
1424diff
changeset | 59 | void *(*calloc)(void *data, size_t nmemb, size_t size); | 
| 429 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 60 | |
| 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 61 | /** | 
| 465 
1e3cb39815f8
remove redundant documentation for function pointers
 Mike Becker <universe@uap-core.de> parents: 
461diff
changeset | 62 | * The allocator's free() implementation. | 
| 429 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 63 | */ | 
| 1426 
3a89b31f0724
clean up header files and adds support for comparing arbitrary strings with string.h functions
 Mike Becker <universe@uap-core.de> parents: 
1424diff
changeset | 64 | void (*free)(void *data, void *mem); | 
| 396 
3539dd99ab92
make cx_allocator_class shared
 Mike Becker <universe@uap-core.de> parents: 
394diff
changeset | 65 | } cx_allocator_class; | 
| 
3539dd99ab92
make cx_allocator_class shared
 Mike Becker <universe@uap-core.de> parents: 
394diff
changeset | 66 | |
| 429 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 67 | /** | 
| 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 68 | * Structure holding the data for an allocator. | 
| 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 69 | */ | 
| 394 
80c31ebd66c1
high level allocator functions should be real functions, not macros
 Mike Becker <universe@uap-core.de> parents: 
393diff
changeset | 70 | struct cx_allocator_s { | 
| 429 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 71 | /** | 
| 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 72 | * A pointer to the instance of the allocator class. | 
| 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 73 | */ | 
| 396 
3539dd99ab92
make cx_allocator_class shared
 Mike Becker <universe@uap-core.de> parents: 
394diff
changeset | 74 | cx_allocator_class *cl; | 
| 429 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 75 | /** | 
| 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 76 | * A pointer to the data this allocator uses. | 
| 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 77 | */ | 
| 397 
cfc1193b1e65
removes unnecessary cx_allocator typedef
 Mike Becker <universe@uap-core.de> parents: 
396diff
changeset | 78 | void *data; | 
| 391 
f094a53c1178
adds allocator interface and default implementation
 Mike Becker <universe@uap-core.de> parents: diff
changeset | 79 | }; | 
| 429 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 80 | |
| 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 81 | /** | 
| 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 82 | * High-Level type alias for the allocator type. | 
| 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 83 | */ | 
| 500 
eb9e7bd40a8e
do not hide pointers behind typedefs
 Mike Becker <universe@uap-core.de> parents: 
484diff
changeset | 84 | typedef struct cx_allocator_s CxAllocator; | 
| 391 
f094a53c1178
adds allocator interface and default implementation
 Mike Becker <universe@uap-core.de> parents: diff
changeset | 85 | |
| 429 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 86 | /** | 
| 1318 
12fa1d37fe48
allow changing the cxDefaultAllocator - resolves #669
 Mike Becker <universe@uap-core.de> parents: 
1188diff
changeset | 87 | * A pre-defined allocator using standard library malloc() etc. | 
| 429 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 88 | */ | 
| 1426 
3a89b31f0724
clean up header files and adds support for comparing arbitrary strings with string.h functions
 Mike Becker <universe@uap-core.de> parents: 
1424diff
changeset | 89 | CX_EXPORT extern const CxAllocator * const cxStdlibAllocator; | 
| 1318 
12fa1d37fe48
allow changing the cxDefaultAllocator - resolves #669
 Mike Becker <universe@uap-core.de> parents: 
1188diff
changeset | 90 | |
| 
12fa1d37fe48
allow changing the cxDefaultAllocator - resolves #669
 Mike Becker <universe@uap-core.de> parents: 
1188diff
changeset | 91 | /** | 
| 
12fa1d37fe48
allow changing the cxDefaultAllocator - resolves #669
 Mike Becker <universe@uap-core.de> parents: 
1188diff
changeset | 92 | * The default allocator that is used by UCX. | 
| 
12fa1d37fe48
allow changing the cxDefaultAllocator - resolves #669
 Mike Becker <universe@uap-core.de> parents: 
1188diff
changeset | 93 | * Initialized with cxStdlibAllocator, but you may change it. | 
| 
12fa1d37fe48
allow changing the cxDefaultAllocator - resolves #669
 Mike Becker <universe@uap-core.de> parents: 
1188diff
changeset | 94 | */ | 
| 1426 
3a89b31f0724
clean up header files and adds support for comparing arbitrary strings with string.h functions
 Mike Becker <universe@uap-core.de> parents: 
1424diff
changeset | 95 | CX_EXPORT extern const CxAllocator * cxDefaultAllocator; | 
| 391 
f094a53c1178
adds allocator interface and default implementation
 Mike Becker <universe@uap-core.de> parents: diff
changeset | 96 | |
| 429 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 97 | /** | 
| 503 
a89857072ace
add new destructor API and apply it to CxList
 Mike Becker <universe@uap-core.de> parents: 
500diff
changeset | 98 | * Function pointer type for destructor functions. | 
| 
a89857072ace
add new destructor API and apply it to CxList
 Mike Becker <universe@uap-core.de> parents: 
500diff
changeset | 99 | * | 
| 
a89857072ace
add new destructor API and apply it to CxList
 Mike Becker <universe@uap-core.de> parents: 
500diff
changeset | 100 | * A destructor function deallocates possible contents and MAY free the memory | 
| 1085 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 101 | * pointed to by @p memory. Read the documentation of the respective function | 
| 985 
68754c7de906
major refactoring of attributes
 Mike Becker <universe@uap-core.de> parents: 
963diff
changeset | 102 | * pointer to learn if a destructor SHALL, MAY, or MUST NOT free the memory in | 
| 
68754c7de906
major refactoring of attributes
 Mike Becker <universe@uap-core.de> parents: 
963diff
changeset | 103 | * that particular implementation. | 
| 503 
a89857072ace
add new destructor API and apply it to CxList
 Mike Becker <universe@uap-core.de> parents: 
500diff
changeset | 104 | * | 
| 
a89857072ace
add new destructor API and apply it to CxList
 Mike Becker <universe@uap-core.de> parents: 
500diff
changeset | 105 | * @param memory a pointer to the object to destruct | 
| 
a89857072ace
add new destructor API and apply it to CxList
 Mike Becker <universe@uap-core.de> parents: 
500diff
changeset | 106 | */ | 
| 891 
49d8cff6f0ee
make all function attributes leading - fixes #425
 Mike Becker <universe@uap-core.de> parents: 
890diff
changeset | 107 | typedef void (*cx_destructor_func)(void *memory); | 
| 503 
a89857072ace
add new destructor API and apply it to CxList
 Mike Becker <universe@uap-core.de> parents: 
500diff
changeset | 108 | |
| 
a89857072ace
add new destructor API and apply it to CxList
 Mike Becker <universe@uap-core.de> parents: 
500diff
changeset | 109 | /** | 
| 528 
4fbfac557df8
#179 improve API for list content destruction
 Mike Becker <universe@uap-core.de> parents: 
526diff
changeset | 110 | * Function pointer type for destructor functions. | 
| 
4fbfac557df8
#179 improve API for list content destruction
 Mike Becker <universe@uap-core.de> parents: 
526diff
changeset | 111 | * | 
| 
4fbfac557df8
#179 improve API for list content destruction
 Mike Becker <universe@uap-core.de> parents: 
526diff
changeset | 112 | * A destructor function deallocates possible contents and MAY free the memory | 
| 1085 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 113 | * pointed to by @p memory. Read the documentation of the respective function | 
| 985 
68754c7de906
major refactoring of attributes
 Mike Becker <universe@uap-core.de> parents: 
963diff
changeset | 114 | * pointer to learn if a destructor SHALL, MAY, or MUST NOT free the memory in | 
| 
68754c7de906
major refactoring of attributes
 Mike Becker <universe@uap-core.de> parents: 
963diff
changeset | 115 | * that particular implementation. | 
| 528 
4fbfac557df8
#179 improve API for list content destruction
 Mike Becker <universe@uap-core.de> parents: 
526diff
changeset | 116 | * | 
| 
4fbfac557df8
#179 improve API for list content destruction
 Mike Becker <universe@uap-core.de> parents: 
526diff
changeset | 117 | * @param data an optional pointer to custom data | 
| 
4fbfac557df8
#179 improve API for list content destruction
 Mike Becker <universe@uap-core.de> parents: 
526diff
changeset | 118 | * @param memory a pointer to the object to destruct | 
| 
4fbfac557df8
#179 improve API for list content destruction
 Mike Becker <universe@uap-core.de> parents: 
526diff
changeset | 119 | */ | 
| 1426 
3a89b31f0724
clean up header files and adds support for comparing arbitrary strings with string.h functions
 Mike Becker <universe@uap-core.de> parents: 
1424diff
changeset | 120 | typedef void (*cx_destructor_func2)(void *data, void *memory); | 
| 528 
4fbfac557df8
#179 improve API for list content destruction
 Mike Becker <universe@uap-core.de> parents: 
526diff
changeset | 121 | |
| 1431 
1ec36e652e57
define the function pointer for clone functions
 Mike Becker <universe@uap-core.de> parents: 
1426diff
changeset | 122 | |
| 
1ec36e652e57
define the function pointer for clone functions
 Mike Becker <universe@uap-core.de> parents: 
1426diff
changeset | 123 | /** | 
| 
1ec36e652e57
define the function pointer for clone functions
 Mike Becker <universe@uap-core.de> parents: 
1426diff
changeset | 124 | * Function pointer type for clone functions. | 
| 
1ec36e652e57
define the function pointer for clone functions
 Mike Becker <universe@uap-core.de> parents: 
1426diff
changeset | 125 | * | 
| 
1ec36e652e57
define the function pointer for clone functions
 Mike Becker <universe@uap-core.de> parents: 
1426diff
changeset | 126 | * A clone function is supposed to create a deep copy of the memory pointed to | 
| 
1ec36e652e57
define the function pointer for clone functions
 Mike Becker <universe@uap-core.de> parents: 
1426diff
changeset | 127 | * by the @p source pointer. | 
| 
1ec36e652e57
define the function pointer for clone functions
 Mike Becker <universe@uap-core.de> parents: 
1426diff
changeset | 128 | * If the @p target pointer is non-null, the clone function is supposed to store | 
| 
1ec36e652e57
define the function pointer for clone functions
 Mike Becker <universe@uap-core.de> parents: 
1426diff
changeset | 129 | * the copy into that memory region. | 
| 
1ec36e652e57
define the function pointer for clone functions
 Mike Becker <universe@uap-core.de> parents: 
1426diff
changeset | 130 | * Otherwise, the clone function shall use the specified @p allocator to create | 
| 
1ec36e652e57
define the function pointer for clone functions
 Mike Becker <universe@uap-core.de> parents: 
1426diff
changeset | 131 | * a new object. | 
| 
1ec36e652e57
define the function pointer for clone functions
 Mike Becker <universe@uap-core.de> parents: 
1426diff
changeset | 132 | * | 
| 
1ec36e652e57
define the function pointer for clone functions
 Mike Becker <universe@uap-core.de> parents: 
1426diff
changeset | 133 | * The return value of a clone function is always a pointer to the target | 
| 
1ec36e652e57
define the function pointer for clone functions
 Mike Becker <universe@uap-core.de> parents: 
1426diff
changeset | 134 | * memory region, or @c NULL if any allocation failed. | 
| 
1ec36e652e57
define the function pointer for clone functions
 Mike Becker <universe@uap-core.de> parents: 
1426diff
changeset | 135 | * A clone function SHOULD NOT fail for any other reason than an allocation | 
| 
1ec36e652e57
define the function pointer for clone functions
 Mike Becker <universe@uap-core.de> parents: 
1426diff
changeset | 136 | * failure. | 
| 
1ec36e652e57
define the function pointer for clone functions
 Mike Becker <universe@uap-core.de> parents: 
1426diff
changeset | 137 | * | 
| 
1ec36e652e57
define the function pointer for clone functions
 Mike Becker <universe@uap-core.de> parents: 
1426diff
changeset | 138 | * @param target the target memory or @c NULL, if memory shall be allocated | 
| 
1ec36e652e57
define the function pointer for clone functions
 Mike Becker <universe@uap-core.de> parents: 
1426diff
changeset | 139 | * @param source the source memory | 
| 
1ec36e652e57
define the function pointer for clone functions
 Mike Becker <universe@uap-core.de> parents: 
1426diff
changeset | 140 | * @param allocator the allocator that shall be used | 
| 
1ec36e652e57
define the function pointer for clone functions
 Mike Becker <universe@uap-core.de> parents: 
1426diff
changeset | 141 | * @param data optional additional data | 
| 
1ec36e652e57
define the function pointer for clone functions
 Mike Becker <universe@uap-core.de> parents: 
1426diff
changeset | 142 | * @return either the specified @p target, a pointer to the allocated memory, | 
| 
1ec36e652e57
define the function pointer for clone functions
 Mike Becker <universe@uap-core.de> parents: 
1426diff
changeset | 143 | * or @c NULL, if any error occurred | 
| 
1ec36e652e57
define the function pointer for clone functions
 Mike Becker <universe@uap-core.de> parents: 
1426diff
changeset | 144 | */ | 
| 
1ec36e652e57
define the function pointer for clone functions
 Mike Becker <universe@uap-core.de> parents: 
1426diff
changeset | 145 | typedef void*(cx_clone_func)(void *target, const void *source, | 
| 
1ec36e652e57
define the function pointer for clone functions
 Mike Becker <universe@uap-core.de> parents: 
1426diff
changeset | 146 | const CxAllocator *allocator, void *data); | 
| 
1ec36e652e57
define the function pointer for clone functions
 Mike Becker <universe@uap-core.de> parents: 
1426diff
changeset | 147 | |
| 528 
4fbfac557df8
#179 improve API for list content destruction
 Mike Becker <universe@uap-core.de> parents: 
526diff
changeset | 148 | /** | 
| 1185 
d825aca193d3
use reallocate instead of re-allocate
 Mike Becker <universe@uap-core.de> parents: 
1180diff
changeset | 149 | * Reallocate a previously allocated block and changes the pointer in-place, | 
| 985 
68754c7de906
major refactoring of attributes
 Mike Becker <universe@uap-core.de> parents: 
963diff
changeset | 150 | * if necessary. | 
| 726 
44986c0e2b05
add a low-level stdlib-based cx_reallocate()
 Mike Becker <universe@uap-core.de> parents: 
677diff
changeset | 151 | * | 
| 1318 
12fa1d37fe48
allow changing the cxDefaultAllocator - resolves #669
 Mike Becker <universe@uap-core.de> parents: 
1188diff
changeset | 152 | * @note This will use stdlib reallocate and @em not the cxDefaultAllocator. | 
| 
12fa1d37fe48
allow changing the cxDefaultAllocator - resolves #669
 Mike Becker <universe@uap-core.de> parents: 
1188diff
changeset | 153 | * | 
| 1085 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 154 | * @par Error handling | 
| 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 155 | * @c errno will be set by realloc() on failure. | 
| 726 
44986c0e2b05
add a low-level stdlib-based cx_reallocate()
 Mike Becker <universe@uap-core.de> parents: 
677diff
changeset | 156 | * | 
| 
44986c0e2b05
add a low-level stdlib-based cx_reallocate()
 Mike Becker <universe@uap-core.de> parents: 
677diff
changeset | 157 | * @param mem pointer to the pointer to allocated block | 
| 
44986c0e2b05
add a low-level stdlib-based cx_reallocate()
 Mike Becker <universe@uap-core.de> parents: 
677diff
changeset | 158 | * @param n the new size in bytes | 
| 1085 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 159 | * @retval zero success | 
| 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 160 | * @retval non-zero failure | 
| 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 161 | * @see cx_reallocatearray() | 
| 726 
44986c0e2b05
add a low-level stdlib-based cx_reallocate()
 Mike Becker <universe@uap-core.de> parents: 
677diff
changeset | 162 | */ | 
| 1426 
3a89b31f0724
clean up header files and adds support for comparing arbitrary strings with string.h functions
 Mike Becker <universe@uap-core.de> parents: 
1424diff
changeset | 163 | cx_attr_nonnull cx_attr_nodiscard | 
| 1431 
1ec36e652e57
define the function pointer for clone functions
 Mike Becker <universe@uap-core.de> parents: 
1426diff
changeset | 164 | CX_EXPORT int cx_reallocate_(void **mem, size_t n); | 
| 726 
44986c0e2b05
add a low-level stdlib-based cx_reallocate()
 Mike Becker <universe@uap-core.de> parents: 
677diff
changeset | 165 | |
| 
44986c0e2b05
add a low-level stdlib-based cx_reallocate()
 Mike Becker <universe@uap-core.de> parents: 
677diff
changeset | 166 | /** | 
| 1185 
d825aca193d3
use reallocate instead of re-allocate
 Mike Becker <universe@uap-core.de> parents: 
1180diff
changeset | 167 | * Reallocate a previously allocated block and changes the pointer in-place, | 
| 985 
68754c7de906
major refactoring of attributes
 Mike Becker <universe@uap-core.de> parents: 
963diff
changeset | 168 | * if necessary. | 
| 935 
312fb24c14de
add convenience macro for cx_reallocate to hide the (void**) cast
 Mike Becker <universe@uap-core.de> parents: 
891diff
changeset | 169 | * | 
| 1085 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 170 | * The size is calculated by multiplying @p nemb and @p size. | 
| 963 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 171 | * | 
| 1318 
12fa1d37fe48
allow changing the cxDefaultAllocator - resolves #669
 Mike Becker <universe@uap-core.de> parents: 
1188diff
changeset | 172 | * @note This will use stdlib reallocate and @em not the cxDefaultAllocator. | 
| 
12fa1d37fe48
allow changing the cxDefaultAllocator - resolves #669
 Mike Becker <universe@uap-core.de> parents: 
1188diff
changeset | 173 | * | 
| 1085 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 174 | * @par Error handling | 
| 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 175 | * @c errno will be set by realloc() on failure or when the multiplication of | 
| 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 176 | * @p nmemb and @p size overflows. | 
| 963 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 177 | * | 
| 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 178 | * @param mem pointer to the pointer to allocated block | 
| 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 179 | * @param nmemb the number of elements | 
| 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 180 | * @param size the size of each element | 
| 1085 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 181 | * @retval zero success | 
| 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 182 | * @retval non-zero failure | 
| 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 183 | * @see cx_reallocate() | 
| 963 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 184 | */ | 
| 1426 
3a89b31f0724
clean up header files and adds support for comparing arbitrary strings with string.h functions
 Mike Becker <universe@uap-core.de> parents: 
1424diff
changeset | 185 | cx_attr_nonnull cx_attr_nodiscard | 
| 
3a89b31f0724
clean up header files and adds support for comparing arbitrary strings with string.h functions
 Mike Becker <universe@uap-core.de> parents: 
1424diff
changeset | 186 | CX_EXPORT int cx_reallocatearray_(void **mem, size_t nmemb, size_t size); | 
| 963 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 187 | |
| 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 188 | /** | 
| 1185 
d825aca193d3
use reallocate instead of re-allocate
 Mike Becker <universe@uap-core.de> parents: 
1180diff
changeset | 189 | * Reallocate a previously allocated block and changes the pointer in-place, | 
| 985 
68754c7de906
major refactoring of attributes
 Mike Becker <universe@uap-core.de> parents: 
963diff
changeset | 190 | * if necessary. | 
| 963 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 191 | * | 
| 1318 
12fa1d37fe48
allow changing the cxDefaultAllocator - resolves #669
 Mike Becker <universe@uap-core.de> parents: 
1188diff
changeset | 192 | * @note This will use stdlib reallocate and @em not the cxDefaultAllocator. | 
| 
12fa1d37fe48
allow changing the cxDefaultAllocator - resolves #669
 Mike Becker <universe@uap-core.de> parents: 
1188diff
changeset | 193 | * | 
| 1085 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 194 | * @par Error handling | 
| 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 195 | * @c errno will be set by realloc() on failure. | 
| 935 
312fb24c14de
add convenience macro for cx_reallocate to hide the (void**) cast
 Mike Becker <universe@uap-core.de> parents: 
891diff
changeset | 196 | * | 
| 1085 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 197 | * @param mem (@c void**) pointer to the pointer to allocated block | 
| 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 198 | * @param n (@c size_t) the new size in bytes | 
| 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 199 | * @retval zero success | 
| 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 200 | * @retval non-zero failure | 
| 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 201 | * @see cx_reallocatearray() | 
| 935 
312fb24c14de
add convenience macro for cx_reallocate to hide the (void**) cast
 Mike Becker <universe@uap-core.de> parents: 
891diff
changeset | 202 | */ | 
| 1134 
60edcd57d54c
fix that some IDEs cannot resolve documentation
 Mike Becker <universe@uap-core.de> parents: 
1087diff
changeset | 203 | #define cx_reallocate(mem, n) cx_reallocate_((void**)(mem), n) | 
| 935 
312fb24c14de
add convenience macro for cx_reallocate to hide the (void**) cast
 Mike Becker <universe@uap-core.de> parents: 
891diff
changeset | 204 | |
| 
312fb24c14de
add convenience macro for cx_reallocate to hide the (void**) cast
 Mike Becker <universe@uap-core.de> parents: 
891diff
changeset | 205 | /** | 
| 1185 
d825aca193d3
use reallocate instead of re-allocate
 Mike Becker <universe@uap-core.de> parents: 
1180diff
changeset | 206 | * Reallocate a previously allocated block and changes the pointer in-place, | 
| 985 
68754c7de906
major refactoring of attributes
 Mike Becker <universe@uap-core.de> parents: 
963diff
changeset | 207 | * if necessary. | 
| 963 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 208 | * | 
| 1085 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 209 | * The size is calculated by multiplying @p nemb and @p size. | 
| 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 210 | * | 
| 1318 
12fa1d37fe48
allow changing the cxDefaultAllocator - resolves #669
 Mike Becker <universe@uap-core.de> parents: 
1188diff
changeset | 211 | * @note This will use stdlib reallocate and @em not the cxDefaultAllocator. | 
| 
12fa1d37fe48
allow changing the cxDefaultAllocator - resolves #669
 Mike Becker <universe@uap-core.de> parents: 
1188diff
changeset | 212 | * | 
| 1085 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 213 | * @par Error handling | 
| 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 214 | * @c errno will be set by realloc() on failure or when the multiplication of | 
| 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 215 | * @p nmemb and @p size overflows. | 
| 963 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 216 | * | 
| 1085 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 217 | * @param mem (@c void**) pointer to the pointer to allocated block | 
| 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 218 | * @param nmemb (@c size_t) the number of elements | 
| 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 219 | * @param size (@c size_t) the size of each element | 
| 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 220 | * @retval zero success | 
| 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 221 | * @retval non-zero failure | 
| 963 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 222 | */ | 
| 985 
68754c7de906
major refactoring of attributes
 Mike Becker <universe@uap-core.de> parents: 
963diff
changeset | 223 | #define cx_reallocatearray(mem, nmemb, size) \ | 
| 1134 
60edcd57d54c
fix that some IDEs cannot resolve documentation
 Mike Becker <universe@uap-core.de> parents: 
1087diff
changeset | 224 | cx_reallocatearray_((void**)(mem), nmemb, size) | 
| 985 
68754c7de906
major refactoring of attributes
 Mike Becker <universe@uap-core.de> parents: 
963diff
changeset | 225 | |
| 
68754c7de906
major refactoring of attributes
 Mike Becker <universe@uap-core.de> parents: 
963diff
changeset | 226 | /** | 
| 1330 
dd5d2402d161
implement zalloc() - resolves #679
 Mike Becker <universe@uap-core.de> parents: 
1319diff
changeset | 227 | * Allocates memory and sets every byte to zero. | 
| 
dd5d2402d161
implement zalloc() - resolves #679
 Mike Becker <universe@uap-core.de> parents: 
1319diff
changeset | 228 | * | 
| 
dd5d2402d161
implement zalloc() - resolves #679
 Mike Becker <universe@uap-core.de> parents: 
1319diff
changeset | 229 | * @param n (@c size_t) the number of bytes | 
| 
dd5d2402d161
implement zalloc() - resolves #679
 Mike Becker <universe@uap-core.de> parents: 
1319diff
changeset | 230 | * @return (@c void*) a pointer to the allocated memory | 
| 
dd5d2402d161
implement zalloc() - resolves #679
 Mike Becker <universe@uap-core.de> parents: 
1319diff
changeset | 231 | */ | 
| 
dd5d2402d161
implement zalloc() - resolves #679
 Mike Becker <universe@uap-core.de> parents: 
1319diff
changeset | 232 | #define cx_zalloc(n) calloc(1, n) | 
| 
dd5d2402d161
implement zalloc() - resolves #679
 Mike Becker <universe@uap-core.de> parents: 
1319diff
changeset | 233 | |
| 
dd5d2402d161
implement zalloc() - resolves #679
 Mike Becker <universe@uap-core.de> parents: 
1319diff
changeset | 234 | /** | 
| 985 
68754c7de906
major refactoring of attributes
 Mike Becker <universe@uap-core.de> parents: 
963diff
changeset | 235 | * Free a block allocated by this allocator. | 
| 
68754c7de906
major refactoring of attributes
 Mike Becker <universe@uap-core.de> parents: 
963diff
changeset | 236 | * | 
| 1085 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 237 | * @note Freeing a block of a different allocator is undefined. | 
| 985 
68754c7de906
major refactoring of attributes
 Mike Becker <universe@uap-core.de> parents: 
963diff
changeset | 238 | * | 
| 
68754c7de906
major refactoring of attributes
 Mike Becker <universe@uap-core.de> parents: 
963diff
changeset | 239 | * @param allocator the allocator | 
| 
68754c7de906
major refactoring of attributes
 Mike Becker <universe@uap-core.de> parents: 
963diff
changeset | 240 | * @param mem a pointer to the block to free | 
| 
68754c7de906
major refactoring of attributes
 Mike Becker <universe@uap-core.de> parents: 
963diff
changeset | 241 | */ | 
| 
68754c7de906
major refactoring of attributes
 Mike Becker <universe@uap-core.de> parents: 
963diff
changeset | 242 | cx_attr_nonnull_arg(1) | 
| 1426 
3a89b31f0724
clean up header files and adds support for comparing arbitrary strings with string.h functions
 Mike Becker <universe@uap-core.de> parents: 
1424diff
changeset | 243 | CX_EXPORT void cxFree(const CxAllocator *allocator, void *mem); | 
| 963 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 244 | |
| 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 245 | /** | 
| 1085 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 246 | * Allocate @p n bytes of memory. | 
| 429 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 247 | * | 
| 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 248 | * @param allocator the allocator | 
| 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 249 | * @param n the number of bytes | 
| 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 250 | * @return a pointer to the allocated memory | 
| 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 251 | */ | 
| 1426 
3a89b31f0724
clean up header files and adds support for comparing arbitrary strings with string.h functions
 Mike Becker <universe@uap-core.de> parents: 
1424diff
changeset | 252 | cx_attr_nodiscard cx_attr_nonnull | 
| 
3a89b31f0724
clean up header files and adds support for comparing arbitrary strings with string.h functions
 Mike Becker <universe@uap-core.de> parents: 
1424diff
changeset | 253 | cx_attr_malloc cx_attr_dealloc_ucx cx_attr_allocsize(2) | 
| 
3a89b31f0724
clean up header files and adds support for comparing arbitrary strings with string.h functions
 Mike Becker <universe@uap-core.de> parents: 
1424diff
changeset | 254 | CX_EXPORT void *cxMalloc(const CxAllocator *allocator, size_t n); | 
| 397 
cfc1193b1e65
removes unnecessary cx_allocator typedef
 Mike Becker <universe@uap-core.de> parents: 
396diff
changeset | 255 | |
| 429 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 256 | /** | 
| 1185 
d825aca193d3
use reallocate instead of re-allocate
 Mike Becker <universe@uap-core.de> parents: 
1180diff
changeset | 257 | * Reallocate the previously allocated block in @p mem, making the new block | 
| 1085 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 258 | * @p n bytes long. | 
| 1424 
563033aa998c
fixes tons of typos and grammar issues across the documentation - fixes #667
 Mike Becker <universe@uap-core.de> parents: 
1330diff
changeset | 259 | * This function may return the same pointer passed to it if moving | 
| 985 
68754c7de906
major refactoring of attributes
 Mike Becker <universe@uap-core.de> parents: 
963diff
changeset | 260 | * the memory was not necessary. | 
| 429 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 261 | * | 
| 1085 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 262 | * @note Re-allocating a block allocated by a different allocator is undefined. | 
| 429 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 263 | * | 
| 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 264 | * @param allocator the allocator | 
| 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 265 | * @param mem pointer to the previously allocated block | 
| 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 266 | * @param n the new size in bytes | 
| 1185 
d825aca193d3
use reallocate instead of re-allocate
 Mike Becker <universe@uap-core.de> parents: 
1180diff
changeset | 267 | * @return a pointer to the reallocated memory | 
| 429 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 268 | */ | 
| 1426 
3a89b31f0724
clean up header files and adds support for comparing arbitrary strings with string.h functions
 Mike Becker <universe@uap-core.de> parents: 
1424diff
changeset | 269 | cx_attr_nodiscard cx_attr_nonnull_arg(1) | 
| 
3a89b31f0724
clean up header files and adds support for comparing arbitrary strings with string.h functions
 Mike Becker <universe@uap-core.de> parents: 
1424diff
changeset | 270 | cx_attr_dealloc_ucx cx_attr_allocsize(3) | 
| 
3a89b31f0724
clean up header files and adds support for comparing arbitrary strings with string.h functions
 Mike Becker <universe@uap-core.de> parents: 
1424diff
changeset | 271 | CX_EXPORT void *cxRealloc(const CxAllocator *allocator, void *mem, size_t n); | 
| 397 
cfc1193b1e65
removes unnecessary cx_allocator typedef
 Mike Becker <universe@uap-core.de> parents: 
396diff
changeset | 272 | |
| 429 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 273 | /** | 
| 1185 
d825aca193d3
use reallocate instead of re-allocate
 Mike Becker <universe@uap-core.de> parents: 
1180diff
changeset | 274 | * Reallocate the previously allocated block in @p mem, making the new block | 
| 1085 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 275 | * @p n bytes long. | 
| 1424 
563033aa998c
fixes tons of typos and grammar issues across the documentation - fixes #667
 Mike Becker <universe@uap-core.de> parents: 
1330diff
changeset | 276 | * This function may return the same pointer passed to it if moving | 
| 985 
68754c7de906
major refactoring of attributes
 Mike Becker <universe@uap-core.de> parents: 
963diff
changeset | 277 | * the memory was not necessary. | 
| 963 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 278 | * | 
| 1085 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 279 | * The size is calculated by multiplying @p nemb and @p size. | 
| 1424 
563033aa998c
fixes tons of typos and grammar issues across the documentation - fixes #667
 Mike Becker <universe@uap-core.de> parents: 
1330diff
changeset | 280 | * If that multiplication overflows, this function returns @c NULL, and @c errno | 
| 985 
68754c7de906
major refactoring of attributes
 Mike Becker <universe@uap-core.de> parents: 
963diff
changeset | 281 | * will be set. | 
| 963 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 282 | * | 
| 1085 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 283 | * @note Re-allocating a block allocated by a different allocator is undefined. | 
| 963 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 284 | * | 
| 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 285 | * @param allocator the allocator | 
| 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 286 | * @param mem pointer to the previously allocated block | 
| 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 287 | * @param nmemb the number of elements | 
| 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 288 | * @param size the size of each element | 
| 1185 
d825aca193d3
use reallocate instead of re-allocate
 Mike Becker <universe@uap-core.de> parents: 
1180diff
changeset | 289 | * @return a pointer to the reallocated memory | 
| 963 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 290 | */ | 
| 1426 
3a89b31f0724
clean up header files and adds support for comparing arbitrary strings with string.h functions
 Mike Becker <universe@uap-core.de> parents: 
1424diff
changeset | 291 | cx_attr_nodiscard cx_attr_nonnull_arg(1) | 
| 
3a89b31f0724
clean up header files and adds support for comparing arbitrary strings with string.h functions
 Mike Becker <universe@uap-core.de> parents: 
1424diff
changeset | 292 | cx_attr_dealloc_ucx cx_attr_allocsize(3, 4) | 
| 
3a89b31f0724
clean up header files and adds support for comparing arbitrary strings with string.h functions
 Mike Becker <universe@uap-core.de> parents: 
1424diff
changeset | 293 | CX_EXPORT void *cxReallocArray(const CxAllocator *allocator, | 
| 
3a89b31f0724
clean up header files and adds support for comparing arbitrary strings with string.h functions
 Mike Becker <universe@uap-core.de> parents: 
1424diff
changeset | 294 | void *mem, size_t nmemb, size_t size); | 
| 963 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 295 | |
| 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 296 | /** | 
| 1185 
d825aca193d3
use reallocate instead of re-allocate
 Mike Becker <universe@uap-core.de> parents: 
1180diff
changeset | 297 | * Reallocate a previously allocated block and changes the pointer in-place, | 
| 985 
68754c7de906
major refactoring of attributes
 Mike Becker <universe@uap-core.de> parents: 
963diff
changeset | 298 | * if necessary. | 
| 1085 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 299 | * This function acts like cxRealloc() using the pointer pointed to by @p mem. | 
| 429 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 300 | * | 
| 1085 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 301 | * @note Re-allocating a block allocated by a different allocator is undefined. | 
| 429 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 302 | * | 
| 1085 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 303 | * @par Error handling | 
| 1424 
563033aa998c
fixes tons of typos and grammar issues across the documentation - fixes #667
 Mike Becker <universe@uap-core.de> parents: 
1330diff
changeset | 304 | * @c errno will be set if the underlying realloc function does so. | 
| 429 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 305 | * | 
| 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 306 | * @param allocator the allocator | 
| 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 307 | * @param mem pointer to the pointer to allocated block | 
| 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 308 | * @param n the new size in bytes | 
| 1085 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 309 | * @retval zero success | 
| 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 310 | * @retval non-zero failure | 
| 429 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 311 | */ | 
| 1426 
3a89b31f0724
clean up header files and adds support for comparing arbitrary strings with string.h functions
 Mike Becker <universe@uap-core.de> parents: 
1424diff
changeset | 312 | cx_attr_nodiscard cx_attr_nonnull | 
| 
3a89b31f0724
clean up header files and adds support for comparing arbitrary strings with string.h functions
 Mike Becker <universe@uap-core.de> parents: 
1424diff
changeset | 313 | CX_EXPORT int cxReallocate_(const CxAllocator *allocator, void **mem, size_t n); | 
| 414 | 314 | |
| 429 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 315 | /** | 
| 1185 
d825aca193d3
use reallocate instead of re-allocate
 Mike Becker <universe@uap-core.de> parents: 
1180diff
changeset | 316 | * Reallocate a previously allocated block and changes the pointer in-place, | 
| 985 
68754c7de906
major refactoring of attributes
 Mike Becker <universe@uap-core.de> parents: 
963diff
changeset | 317 | * if necessary. | 
| 1085 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 318 | * This function acts like cxRealloc() using the pointer pointed to by @p mem. | 
| 963 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 319 | * | 
| 1085 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 320 | * @note Re-allocating a block allocated by a different allocator is undefined. | 
| 963 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 321 | * | 
| 1085 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 322 | * @par Error handling | 
| 1424 
563033aa998c
fixes tons of typos and grammar issues across the documentation - fixes #667
 Mike Becker <universe@uap-core.de> parents: 
1330diff
changeset | 323 | * @c errno will be set if the underlying realloc function does so. | 
| 963 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 324 | * | 
| 1087 
128324af5164
don't document constness of arguments in macros
 Mike Becker <universe@uap-core.de> parents: 
1085diff
changeset | 325 | * @param allocator (@c CxAllocator*) the allocator | 
| 1085 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 326 | * @param mem (@c void**) pointer to the pointer to allocated block | 
| 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 327 | * @param n (@c size_t) the new size in bytes | 
| 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 328 | * @retval zero success | 
| 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 329 | * @retval non-zero failure | 
| 963 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 330 | */ | 
| 985 
68754c7de906
major refactoring of attributes
 Mike Becker <universe@uap-core.de> parents: 
963diff
changeset | 331 | #define cxReallocate(allocator, mem, n) \ | 
| 1134 
60edcd57d54c
fix that some IDEs cannot resolve documentation
 Mike Becker <universe@uap-core.de> parents: 
1087diff
changeset | 332 | cxReallocate_(allocator, (void**)(mem), n) | 
| 963 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 333 | |
| 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 334 | /** | 
| 1185 
d825aca193d3
use reallocate instead of re-allocate
 Mike Becker <universe@uap-core.de> parents: 
1180diff
changeset | 335 | * Reallocate a previously allocated block and changes the pointer in-place, | 
| 985 
68754c7de906
major refactoring of attributes
 Mike Becker <universe@uap-core.de> parents: 
963diff
changeset | 336 | * if necessary. | 
| 
68754c7de906
major refactoring of attributes
 Mike Becker <universe@uap-core.de> parents: 
963diff
changeset | 337 | * This function acts like cxReallocArray() using the pointer pointed to | 
| 1085 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 338 | * by @p mem. | 
| 963 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 339 | * | 
| 1085 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 340 | * @note Re-allocating a block allocated by a different allocator is undefined. | 
| 963 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 341 | * | 
| 1085 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 342 | * @par Error handling | 
| 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 343 | * @c errno will be set, if the underlying realloc function does so or the | 
| 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 344 | * multiplication of @p nmemb and @p size overflows. | 
| 963 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 345 | * | 
| 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 346 | * @param allocator the allocator | 
| 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 347 | * @param mem pointer to the pointer to allocated block | 
| 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 348 | * @param nmemb the number of elements | 
| 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 349 | * @param size the size of each element | 
| 1085 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 350 | * @retval zero success | 
| 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 351 | * @retval non-zero on failure | 
| 963 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 352 | */ | 
| 1426 
3a89b31f0724
clean up header files and adds support for comparing arbitrary strings with string.h functions
 Mike Becker <universe@uap-core.de> parents: 
1424diff
changeset | 353 | cx_attr_nodiscard cx_attr_nonnull | 
| 
3a89b31f0724
clean up header files and adds support for comparing arbitrary strings with string.h functions
 Mike Becker <universe@uap-core.de> parents: 
1424diff
changeset | 354 | CX_EXPORT int cxReallocateArray_(const CxAllocator *allocator, | 
| 
3a89b31f0724
clean up header files and adds support for comparing arbitrary strings with string.h functions
 Mike Becker <universe@uap-core.de> parents: 
1424diff
changeset | 355 | void **mem, size_t nmemb, size_t size); | 
| 963 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 356 | |
| 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 357 | /** | 
| 1185 
d825aca193d3
use reallocate instead of re-allocate
 Mike Becker <universe@uap-core.de> parents: 
1180diff
changeset | 358 | * Reallocate a previously allocated block and changes the pointer in-place, | 
| 985 
68754c7de906
major refactoring of attributes
 Mike Becker <universe@uap-core.de> parents: 
963diff
changeset | 359 | * if necessary. | 
| 
68754c7de906
major refactoring of attributes
 Mike Becker <universe@uap-core.de> parents: 
963diff
changeset | 360 | * This function acts like cxReallocArray() using the pointer pointed to | 
| 1085 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 361 | * by @p mem. | 
| 963 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 362 | * | 
| 1085 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 363 | * @note Re-allocating a block allocated by a different allocator is undefined. | 
| 963 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 364 | * | 
| 1085 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 365 | * @par Error handling | 
| 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 366 | * @c errno will be set, if the underlying realloc function does so or the | 
| 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 367 | * multiplication of @p nmemb and @p size overflows. | 
| 963 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 368 | * | 
| 1087 
128324af5164
don't document constness of arguments in macros
 Mike Becker <universe@uap-core.de> parents: 
1085diff
changeset | 369 | * @param allocator (@c CxAllocator*) the allocator | 
| 1085 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 370 | * @param mem (@c void**) pointer to the pointer to allocated block | 
| 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 371 | * @param nmemb (@c size_t) the number of elements | 
| 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 372 | * @param size (@c size_t) the size of each element | 
| 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 373 | * @retval zero success | 
| 
b8e0b4130cc3
refine docs for allocator.h - issue #548
 Mike Becker <universe@uap-core.de> parents: 
985diff
changeset | 374 | * @retval non-zero failure | 
| 963 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 375 | */ | 
| 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 376 | #define cxReallocateArray(allocator, mem, nmemb, size) \ | 
| 1134 
60edcd57d54c
fix that some IDEs cannot resolve documentation
 Mike Becker <universe@uap-core.de> parents: 
1087diff
changeset | 377 | cxReallocateArray_(allocator, (void**) (mem), nmemb, size) | 
| 963 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 378 | |
| 
2f601274bbac
add reallocarray() like functions - resolves #468
 Mike Becker <universe@uap-core.de> parents: 
935diff
changeset | 379 | /** | 
| 1169 
6a33a5648027
add documentation for allocator.h
 Mike Becker <universe@uap-core.de> parents: 
1134diff
changeset | 380 | * Allocate @p nmemb elements of @p n bytes each, all initialized to zero. | 
| 429 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 381 | * | 
| 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 382 | * @param allocator the allocator | 
| 1169 
6a33a5648027
add documentation for allocator.h
 Mike Becker <universe@uap-core.de> parents: 
1134diff
changeset | 383 | * @param nmemb the number of elements | 
| 
6a33a5648027
add documentation for allocator.h
 Mike Becker <universe@uap-core.de> parents: 
1134diff
changeset | 384 | * @param size the size of each element in bytes | 
| 429 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 385 | * @return a pointer to the allocated memory | 
| 
3d8235c96a27
add documentation to allocator.h
 Mike Becker <universe@uap-core.de> parents: 
419diff
changeset | 386 | */ | 
| 1426 
3a89b31f0724
clean up header files and adds support for comparing arbitrary strings with string.h functions
 Mike Becker <universe@uap-core.de> parents: 
1424diff
changeset | 387 | cx_attr_nonnull_arg(1) cx_attr_nodiscard | 
| 
3a89b31f0724
clean up header files and adds support for comparing arbitrary strings with string.h functions
 Mike Becker <universe@uap-core.de> parents: 
1424diff
changeset | 388 | cx_attr_malloc cx_attr_dealloc_ucx cx_attr_allocsize(2, 3) | 
| 
3a89b31f0724
clean up header files and adds support for comparing arbitrary strings with string.h functions
 Mike Becker <universe@uap-core.de> parents: 
1424diff
changeset | 389 | CX_EXPORT void *cxCalloc(const CxAllocator *allocator, size_t nmemb, size_t size); | 
| 397 
cfc1193b1e65
removes unnecessary cx_allocator typedef
 Mike Becker <universe@uap-core.de> parents: 
396diff
changeset | 390 | |
| 1330 
dd5d2402d161
implement zalloc() - resolves #679
 Mike Becker <universe@uap-core.de> parents: 
1319diff
changeset | 391 | /** | 
| 
dd5d2402d161
implement zalloc() - resolves #679
 Mike Becker <universe@uap-core.de> parents: 
1319diff
changeset | 392 | * Allocate @p n bytes of memory and sets every byte to zero. | 
| 
dd5d2402d161
implement zalloc() - resolves #679
 Mike Becker <universe@uap-core.de> parents: 
1319diff
changeset | 393 | * | 
| 
dd5d2402d161
implement zalloc() - resolves #679
 Mike Becker <universe@uap-core.de> parents: 
1319diff
changeset | 394 | * @param allocator the allocator | 
| 
dd5d2402d161
implement zalloc() - resolves #679
 Mike Becker <universe@uap-core.de> parents: 
1319diff
changeset | 395 | * @param n the number of bytes | 
| 
dd5d2402d161
implement zalloc() - resolves #679
 Mike Becker <universe@uap-core.de> parents: 
1319diff
changeset | 396 | * @return a pointer to the allocated memory | 
| 
dd5d2402d161
implement zalloc() - resolves #679
 Mike Becker <universe@uap-core.de> parents: 
1319diff
changeset | 397 | */ | 
| 1426 
3a89b31f0724
clean up header files and adds support for comparing arbitrary strings with string.h functions
 Mike Becker <universe@uap-core.de> parents: 
1424diff
changeset | 398 | cx_attr_nodiscard cx_attr_nonnull | 
| 
3a89b31f0724
clean up header files and adds support for comparing arbitrary strings with string.h functions
 Mike Becker <universe@uap-core.de> parents: 
1424diff
changeset | 399 | cx_attr_malloc cx_attr_dealloc_ucx cx_attr_allocsize(2) | 
| 
3a89b31f0724
clean up header files and adds support for comparing arbitrary strings with string.h functions
 Mike Becker <universe@uap-core.de> parents: 
1424diff
changeset | 400 | CX_EXPORT void *cxZalloc(const CxAllocator *allocator, size_t n); | 
| 1319 
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
 Mike Becker <universe@uap-core.de> parents: 
1318diff
changeset | 401 | |
| 
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
 Mike Becker <universe@uap-core.de> parents: 
1318diff
changeset | 402 | /** | 
| 
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
 Mike Becker <universe@uap-core.de> parents: 
1318diff
changeset | 403 | * Convenience macro that invokes cxMalloc() with the cxDefaultAllocator. | 
| 
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
 Mike Becker <universe@uap-core.de> parents: 
1318diff
changeset | 404 | */ | 
| 
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
 Mike Becker <universe@uap-core.de> parents: 
1318diff
changeset | 405 | #define cxMallocDefault(...) cxMalloc(cxDefaultAllocator, __VA_ARGS__) | 
| 
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
 Mike Becker <universe@uap-core.de> parents: 
1318diff
changeset | 406 | /** | 
| 1330 
dd5d2402d161
implement zalloc() - resolves #679
 Mike Becker <universe@uap-core.de> parents: 
1319diff
changeset | 407 | * Convenience macro that invokes cxZalloc() with the cxDefaultAllocator. | 
| 
dd5d2402d161
implement zalloc() - resolves #679
 Mike Becker <universe@uap-core.de> parents: 
1319diff
changeset | 408 | */ | 
| 
dd5d2402d161
implement zalloc() - resolves #679
 Mike Becker <universe@uap-core.de> parents: 
1319diff
changeset | 409 | #define cxZallocDefault(...) cxZalloc(cxDefaultAllocator, __VA_ARGS__) | 
| 
dd5d2402d161
implement zalloc() - resolves #679
 Mike Becker <universe@uap-core.de> parents: 
1319diff
changeset | 410 | /** | 
| 1319 
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
 Mike Becker <universe@uap-core.de> parents: 
1318diff
changeset | 411 | * Convenience macro that invokes cxCalloc() with the cxDefaultAllocator. | 
| 
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
 Mike Becker <universe@uap-core.de> parents: 
1318diff
changeset | 412 | */ | 
| 
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
 Mike Becker <universe@uap-core.de> parents: 
1318diff
changeset | 413 | #define cxCallocDefault(...) cxCalloc(cxDefaultAllocator, __VA_ARGS__) | 
| 
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
 Mike Becker <universe@uap-core.de> parents: 
1318diff
changeset | 414 | /** | 
| 
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
 Mike Becker <universe@uap-core.de> parents: 
1318diff
changeset | 415 | * Convenience macro that invokes cxRealloc() with the cxDefaultAllocator. | 
| 
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
 Mike Becker <universe@uap-core.de> parents: 
1318diff
changeset | 416 | */ | 
| 
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
 Mike Becker <universe@uap-core.de> parents: 
1318diff
changeset | 417 | #define cxReallocDefault(...) cxRealloc(cxDefaultAllocator, __VA_ARGS__) | 
| 
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
 Mike Becker <universe@uap-core.de> parents: 
1318diff
changeset | 418 | /** | 
| 
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
 Mike Becker <universe@uap-core.de> parents: 
1318diff
changeset | 419 | * Convenience macro that invokes cxReallocate() with the cxDefaultAllocator. | 
| 
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
 Mike Becker <universe@uap-core.de> parents: 
1318diff
changeset | 420 | */ | 
| 
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
 Mike Becker <universe@uap-core.de> parents: 
1318diff
changeset | 421 | #define cxReallocateDefault(...) cxReallocate(cxDefaultAllocator, __VA_ARGS__) | 
| 
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
 Mike Becker <universe@uap-core.de> parents: 
1318diff
changeset | 422 | /** | 
| 
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
 Mike Becker <universe@uap-core.de> parents: 
1318diff
changeset | 423 | * Convenience macro that invokes cxReallocateArray() with the cxDefaultAllocator. | 
| 
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
 Mike Becker <universe@uap-core.de> parents: 
1318diff
changeset | 424 | */ | 
| 
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
 Mike Becker <universe@uap-core.de> parents: 
1318diff
changeset | 425 | #define cxReallocateArrayDefault(...) cxReallocateArray(cxDefaultAllocator, __VA_ARGS__) | 
| 
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
 Mike Becker <universe@uap-core.de> parents: 
1318diff
changeset | 426 | /** | 
| 
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
 Mike Becker <universe@uap-core.de> parents: 
1318diff
changeset | 427 | * Convenience macro that invokes cxReallocArray() with the cxDefaultAllocator. | 
| 
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
 Mike Becker <universe@uap-core.de> parents: 
1318diff
changeset | 428 | */ | 
| 
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
 Mike Becker <universe@uap-core.de> parents: 
1318diff
changeset | 429 | #define cxReallocArrayDefault(...) cxReallocArray(cxDefaultAllocator, __VA_ARGS__) | 
| 
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
 Mike Becker <universe@uap-core.de> parents: 
1318diff
changeset | 430 | /** | 
| 
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
 Mike Becker <universe@uap-core.de> parents: 
1318diff
changeset | 431 | * Convenience macro that invokes cxFree() with the cxDefaultAllocator. | 
| 
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
 Mike Becker <universe@uap-core.de> parents: 
1318diff
changeset | 432 | */ | 
| 
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
 Mike Becker <universe@uap-core.de> parents: 
1318diff
changeset | 433 | #define cxFreeDefault(...) cxFree(cxDefaultAllocator, __VA_ARGS__) | 
| 
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
 Mike Becker <universe@uap-core.de> parents: 
1318diff
changeset | 434 | |
| 415 | 435 | #ifdef __cplusplus | 
| 628 
1e2be40f0cb5
use //-style single line comments everywhere
 Mike Becker <universe@uap-core.de> parents: 
528diff
changeset | 436 | } // extern "C" | 
| 415 | 437 | #endif | 
| 438 | ||
| 628 
1e2be40f0cb5
use //-style single line comments everywhere
 Mike Becker <universe@uap-core.de> parents: 
528diff
changeset | 439 | #endif // UCX_ALLOCATOR_H |