ucx/cx/allocator.h

Tue, 09 Sep 2025 20:56:47 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Tue, 09 Sep 2025 20:56:47 +0200
branch
dav-2
changeset 886
da79af4baec8
parent 854
1c8401ece69e
child 889
42cdbf9bbd49
permissions
-rw-r--r--

update ucx

747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4 * Copyright 2021 Mike Becker, Olaf Wintermann All rights reserved.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28 /**
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
29 * @file allocator.h
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30 * Interface for custom allocators.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31 */
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33 #ifndef UCX_ALLOCATOR_H
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
34 #define UCX_ALLOCATOR_H
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
35
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36 #include "common.h"
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
37
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
38 #ifdef __cplusplus
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39 extern "C" {
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40 #endif
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42 /**
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
43 * The class definition for an allocator.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44 */
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
45 typedef struct {
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
46 /**
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
47 * The allocator's malloc() implementation.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
48 */
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
49 void *(*malloc)(
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
50 void *data,
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
51 size_t n
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
52 );
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
53
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
54 /**
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
55 * The allocator's realloc() implementation.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
56 */
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
57 void *(*realloc)(
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
58 void *data,
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
59 void *mem,
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
60 size_t n
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
61 );
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
62
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
63 /**
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
64 * The allocator's calloc() implementation.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
65 */
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
66 void *(*calloc)(
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
67 void *data,
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
68 size_t nmemb,
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
69 size_t size
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
70 );
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
71
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
72 /**
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
73 * The allocator's free() implementation.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
74 */
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
75 void (*free)(
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
76 void *data,
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
77 void *mem
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
78 );
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
79 } cx_allocator_class;
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
80
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
81 /**
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
82 * Structure holding the data for an allocator.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
83 */
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
84 struct cx_allocator_s {
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
85 /**
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
86 * A pointer to the instance of the allocator class.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
87 */
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
88 cx_allocator_class *cl;
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
89 /**
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
90 * A pointer to the data this allocator uses.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
91 */
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
92 void *data;
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
93 };
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
94
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
95 /**
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
96 * High-Level type alias for the allocator type.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
97 */
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
98 typedef struct cx_allocator_s CxAllocator;
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
99
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
100 /**
886
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
101 * A pre-defined allocator using standard library malloc() etc.
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
102 */
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
103 cx_attr_export
886
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
104 extern const CxAllocator * const cxStdlibAllocator;
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
105
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
106 /**
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
107 * The default allocator that is used by UCX.
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
108 * Initialized with cxStdlibAllocator, but you may change it.
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
109 */
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
110 cx_attr_export
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
111 extern const CxAllocator * cxDefaultAllocator;
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
112
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
113 /**
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
114 * Function pointer type for destructor functions.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
115 *
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
116 * A destructor function deallocates possible contents and MAY free the memory
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
117 * pointed to by @p memory. Read the documentation of the respective function
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
118 * pointer to learn if a destructor SHALL, MAY, or MUST NOT free the memory in
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
119 * that particular implementation.
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
120 *
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
121 * @param memory a pointer to the object to destruct
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
122 */
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
123 typedef void (*cx_destructor_func)(void *memory);
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
124
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
125 /**
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
126 * Function pointer type for destructor functions.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
127 *
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
128 * A destructor function deallocates possible contents and MAY free the memory
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
129 * pointed to by @p memory. Read the documentation of the respective function
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
130 * pointer to learn if a destructor SHALL, MAY, or MUST NOT free the memory in
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
131 * that particular implementation.
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
132 *
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
133 * @param data an optional pointer to custom data
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
134 * @param memory a pointer to the object to destruct
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
135 */
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
136 typedef void (*cx_destructor_func2)(
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
137 void *data,
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
138 void *memory
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
139 );
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
140
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
141 /**
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
142 * Reallocate a previously allocated block and changes the pointer in-place,
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
143 * if necessary.
775
e5909dff0dbf update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 747
diff changeset
144 *
886
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
145 * @note This will use stdlib reallocate and @em not the cxDefaultAllocator.
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
146 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
147 * @par Error handling
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
148 * @c errno will be set by realloc() on failure.
775
e5909dff0dbf update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 747
diff changeset
149 *
e5909dff0dbf update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 747
diff changeset
150 * @param mem pointer to the pointer to allocated block
e5909dff0dbf update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 747
diff changeset
151 * @param n the new size in bytes
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
152 * @retval zero success
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
153 * @retval non-zero failure
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
154 * @see cx_reallocatearray()
775
e5909dff0dbf update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 747
diff changeset
155 */
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
156 cx_attr_nonnull
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
157 cx_attr_nodiscard
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
158 cx_attr_export
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
159 int cx_reallocate_(
775
e5909dff0dbf update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 747
diff changeset
160 void **mem,
e5909dff0dbf update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 747
diff changeset
161 size_t n
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
162 );
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
163
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
164 /**
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
165 * Reallocate a previously allocated block and changes the pointer in-place,
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
166 * if necessary.
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
167 *
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
168 * The size is calculated by multiplying @p nemb and @p size.
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
169 *
886
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
170 * @note This will use stdlib reallocate and @em not the cxDefaultAllocator.
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
171 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
172 * @par Error handling
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
173 * @c errno will be set by realloc() on failure or when the multiplication of
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
174 * @p nmemb and @p size overflows.
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
175 *
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
176 * @param mem pointer to the pointer to allocated block
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
177 * @param nmemb the number of elements
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
178 * @param size the size of each element
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
179 * @retval zero success
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
180 * @retval non-zero failure
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
181 * @see cx_reallocate()
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
182 */
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
183 cx_attr_nonnull
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
184 cx_attr_nodiscard
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
185 cx_attr_export
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
186 int cx_reallocatearray_(
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
187 void **mem,
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
188 size_t nmemb,
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
189 size_t size
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
190 );
775
e5909dff0dbf update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 747
diff changeset
191
e5909dff0dbf update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 747
diff changeset
192 /**
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
193 * Reallocate a previously allocated block and changes the pointer in-place,
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
194 * if necessary.
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
195 *
886
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
196 * @note This will use stdlib reallocate and @em not the cxDefaultAllocator.
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
197 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
198 * @par Error handling
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
199 * @c errno will be set by realloc() on failure.
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
200 *
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
201 * @param mem (@c void**) pointer to the pointer to allocated block
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
202 * @param n (@c size_t) the new size in bytes
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
203 * @retval zero success
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
204 * @retval non-zero failure
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
205 * @see cx_reallocatearray()
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
206 */
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
207 #define cx_reallocate(mem, n) cx_reallocate_((void**)(mem), n)
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
208
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
209 /**
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
210 * Reallocate a previously allocated block and changes the pointer in-place,
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
211 * if necessary.
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
212 *
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
213 * The size is calculated by multiplying @p nemb and @p size.
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
214 *
886
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
215 * @note This will use stdlib reallocate and @em not the cxDefaultAllocator.
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
216 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
217 * @par Error handling
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
218 * @c errno will be set by realloc() on failure or when the multiplication of
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
219 * @p nmemb and @p size overflows.
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
220 *
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
221 * @param mem (@c void**) pointer to the pointer to allocated block
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
222 * @param nmemb (@c size_t) the number of elements
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
223 * @param size (@c size_t) the size of each element
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
224 * @retval zero success
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
225 * @retval non-zero failure
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
226 */
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
227 #define cx_reallocatearray(mem, nmemb, size) \
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
228 cx_reallocatearray_((void**)(mem), nmemb, size)
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
229
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
230 /**
886
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
231 * Allocates memory and sets every byte to zero.
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
232 *
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
233 * @param n (@c size_t) the number of bytes
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
234 * @return (@c void*) a pointer to the allocated memory
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
235 */
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
236 #define cx_zalloc(n) calloc(1, n)
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
237
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
238 /**
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
239 * Free a block allocated by this allocator.
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
240 *
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
241 * @note Freeing a block of a different allocator is undefined.
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
242 *
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
243 * @param allocator the allocator
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
244 * @param mem a pointer to the block to free
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
245 */
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
246 cx_attr_nonnull_arg(1)
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
247 cx_attr_export
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
248 void cxFree(
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
249 const CxAllocator *allocator,
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
250 void *mem
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
251 );
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
252
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
253 /**
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
254 * Allocate @p n bytes of memory.
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
255 *
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
256 * @param allocator the allocator
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
257 * @param n the number of bytes
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
258 * @return a pointer to the allocated memory
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
259 */
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
260 cx_attr_nodiscard
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
261 cx_attr_nonnull
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
262 cx_attr_malloc
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
263 cx_attr_dealloc_ucx
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
264 cx_attr_allocsize(2)
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
265 cx_attr_export
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
266 void *cxMalloc(
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
267 const CxAllocator *allocator,
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
268 size_t n
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
269 );
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
270
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
271 /**
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
272 * Reallocate the previously allocated block in @p mem, making the new block
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
273 * @p n bytes long.
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
274 * This function may return the same pointer that was passed to it, if moving
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
275 * the memory was not necessary.
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
276 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
277 * @note Re-allocating a block allocated by a different allocator is undefined.
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
278 *
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
279 * @param allocator the allocator
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
280 * @param mem pointer to the previously allocated block
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
281 * @param n the new size in bytes
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
282 * @return a pointer to the reallocated memory
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
283 */
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
284 cx_attr_nodiscard
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
285 cx_attr_nonnull_arg(1)
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
286 cx_attr_dealloc_ucx
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
287 cx_attr_allocsize(3)
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
288 cx_attr_export
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
289 void *cxRealloc(
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
290 const CxAllocator *allocator,
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
291 void *mem,
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
292 size_t n
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
293 );
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
294
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
295 /**
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
296 * Reallocate the previously allocated block in @p mem, making the new block
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
297 * @p n bytes long.
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
298 * This function may return the same pointer that was passed to it, if moving
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
299 * the memory was not necessary.
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
300 *
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
301 * The size is calculated by multiplying @p nemb and @p size.
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
302 * If that multiplication overflows, this function returns @c NULL and @c errno
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
303 * will be set.
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
304 *
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
305 * @note Re-allocating a block allocated by a different allocator is undefined.
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
306 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
307 * @param allocator the allocator
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
308 * @param mem pointer to the previously allocated block
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
309 * @param nmemb the number of elements
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
310 * @param size the size of each element
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
311 * @return a pointer to the reallocated memory
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
312 */
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
313 cx_attr_nodiscard
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
314 cx_attr_nonnull_arg(1)
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
315 cx_attr_dealloc_ucx
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
316 cx_attr_allocsize(3, 4)
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
317 cx_attr_export
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
318 void *cxReallocArray(
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
319 const CxAllocator *allocator,
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
320 void *mem,
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
321 size_t nmemb,
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
322 size_t size
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
323 );
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
324
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
325 /**
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
326 * Reallocate a previously allocated block and changes the pointer in-place,
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
327 * if necessary.
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
328 * This function acts like cxRealloc() using the pointer pointed to by @p mem.
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
329 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
330 * @note Re-allocating a block allocated by a different allocator is undefined.
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
331 *
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
332 * @par Error handling
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
333 * @c errno will be set, if the underlying realloc function does so.
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
334 *
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
335 * @param allocator the allocator
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
336 * @param mem pointer to the pointer to allocated block
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
337 * @param n the new size in bytes
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
338 * @retval zero success
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
339 * @retval non-zero failure
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
340 */
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
341 cx_attr_nodiscard
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
342 cx_attr_nonnull
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
343 cx_attr_export
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
344 int cxReallocate_(
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
345 const CxAllocator *allocator,
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
346 void **mem,
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
347 size_t n
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
348 );
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
349
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
350 /**
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
351 * Reallocate a previously allocated block and changes the pointer in-place,
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
352 * if necessary.
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
353 * This function acts like cxRealloc() using the pointer pointed to by @p mem.
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
354 *
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
355 * @note Re-allocating a block allocated by a different allocator is undefined.
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
356 *
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
357 * @par Error handling
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
358 * @c errno will be set, if the underlying realloc function does so.
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
359 *
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
360 * @param allocator (@c CxAllocator*) the allocator
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
361 * @param mem (@c void**) pointer to the pointer to allocated block
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
362 * @param n (@c size_t) the new size in bytes
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
363 * @retval zero success
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
364 * @retval non-zero failure
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
365 */
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
366 #define cxReallocate(allocator, mem, n) \
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
367 cxReallocate_(allocator, (void**)(mem), n)
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
368
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
369 /**
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
370 * Reallocate a previously allocated block and changes the pointer in-place,
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
371 * if necessary.
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
372 * This function acts like cxReallocArray() using the pointer pointed to
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
373 * by @p mem.
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
374 *
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
375 * @note Re-allocating a block allocated by a different allocator is undefined.
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
376 *
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
377 * @par Error handling
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
378 * @c errno will be set, if the underlying realloc function does so or the
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
379 * multiplication of @p nmemb and @p size overflows.
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
380 *
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
381 * @param allocator the allocator
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
382 * @param mem pointer to the pointer to allocated block
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
383 * @param nmemb the number of elements
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
384 * @param size the size of each element
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
385 * @retval zero success
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
386 * @retval non-zero on failure
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
387 */
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
388 cx_attr_nodiscard
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
389 cx_attr_nonnull
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
390 cx_attr_export
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
391 int cxReallocateArray_(
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
392 const CxAllocator *allocator,
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
393 void **mem,
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
394 size_t nmemb,
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
395 size_t size
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
396 );
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
397
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
398 /**
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
399 * Reallocate a previously allocated block and changes the pointer in-place,
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
400 * if necessary.
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
401 * This function acts like cxReallocArray() using the pointer pointed to
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
402 * by @p mem.
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
403 *
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
404 * @note Re-allocating a block allocated by a different allocator is undefined.
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
405 *
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
406 * @par Error handling
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
407 * @c errno will be set, if the underlying realloc function does so or the
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
408 * multiplication of @p nmemb and @p size overflows.
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
409 *
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
410 * @param allocator (@c CxAllocator*) the allocator
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
411 * @param mem (@c void**) pointer to the pointer to allocated block
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
412 * @param nmemb (@c size_t) the number of elements
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
413 * @param size (@c size_t) the size of each element
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
414 * @retval zero success
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
415 * @retval non-zero failure
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
416 */
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
417 #define cxReallocateArray(allocator, mem, nmemb, size) \
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
418 cxReallocateArray_(allocator, (void**) (mem), nmemb, size)
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
419
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
420 /**
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
421 * Allocate @p nmemb elements of @p n bytes each, all initialized to zero.
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
422 *
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
423 * @param allocator the allocator
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
424 * @param nmemb the number of elements
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
425 * @param size the size of each element in bytes
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
426 * @return a pointer to the allocated memory
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
427 */
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
428 cx_attr_nonnull_arg(1)
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
429 cx_attr_nodiscard
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
430 cx_attr_malloc
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
431 cx_attr_dealloc_ucx
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
432 cx_attr_allocsize(2, 3)
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
433 cx_attr_export
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
434 void *cxCalloc(
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
435 const CxAllocator *allocator,
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
436 size_t nmemb,
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
437 size_t size
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 775
diff changeset
438 );
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
439
886
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
440 /**
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
441 * Allocate @p n bytes of memory and sets every byte to zero.
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
442 *
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
443 * @param allocator the allocator
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
444 * @param n the number of bytes
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
445 * @return a pointer to the allocated memory
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
446 */
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
447 cx_attr_nodiscard
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
448 cx_attr_nonnull
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
449 cx_attr_malloc
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
450 cx_attr_dealloc_ucx
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
451 cx_attr_allocsize(2)
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
452 cx_attr_export
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
453 void *cxZalloc(
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
454 const CxAllocator *allocator,
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
455 size_t n
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
456 );
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
457
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
458 /**
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
459 * Convenience macro that invokes cxMalloc() with the cxDefaultAllocator.
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
460 */
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
461 #define cxMallocDefault(...) cxMalloc(cxDefaultAllocator, __VA_ARGS__)
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
462 /**
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
463 * Convenience macro that invokes cxZalloc() with the cxDefaultAllocator.
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
464 */
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
465 #define cxZallocDefault(...) cxZalloc(cxDefaultAllocator, __VA_ARGS__)
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
466 /**
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
467 * Convenience macro that invokes cxCalloc() with the cxDefaultAllocator.
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
468 */
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
469 #define cxCallocDefault(...) cxCalloc(cxDefaultAllocator, __VA_ARGS__)
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
470 /**
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
471 * Convenience macro that invokes cxRealloc() with the cxDefaultAllocator.
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
472 */
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
473 #define cxReallocDefault(...) cxRealloc(cxDefaultAllocator, __VA_ARGS__)
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
474 /**
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
475 * Convenience macro that invokes cxReallocate() with the cxDefaultAllocator.
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
476 */
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
477 #define cxReallocateDefault(...) cxReallocate(cxDefaultAllocator, __VA_ARGS__)
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
478 /**
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
479 * Convenience macro that invokes cxReallocateArray() with the cxDefaultAllocator.
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
480 */
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
481 #define cxReallocateArrayDefault(...) cxReallocateArray(cxDefaultAllocator, __VA_ARGS__)
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
482 /**
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
483 * Convenience macro that invokes cxReallocArray() with the cxDefaultAllocator.
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
484 */
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
485 #define cxReallocArrayDefault(...) cxReallocArray(cxDefaultAllocator, __VA_ARGS__)
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
486 /**
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
487 * Convenience macro that invokes cxFree() with the cxDefaultAllocator.
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
488 */
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
489 #define cxFreeDefault(...) cxFree(cxDefaultAllocator, __VA_ARGS__)
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
490
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
491 #ifdef __cplusplus
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
492 } // extern "C"
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
493 #endif
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
494
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
495 #endif // UCX_ALLOCATOR_H

mercurial