1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
/* Allocator structure. An instance of this will be passed around for anything needing memory allocation */
;
/**
* Inexpensive (constant time) check of data-structure invariants.
*/
bool ;
struct aws_allocator *;
/* Avoid pulling in CoreFoundation headers in a header file. */
;
typedef const struct __CFAllocator *CFAllocatorRef;
/**
* Wraps a CFAllocator around aws_allocator. For Mac only. Use this anytime you need a CFAllocatorRef for interacting
* with Apple Frameworks. Unfortunately, it allocates memory so we can't make it static file scope, be sure to call
* aws_wrapped_cf_allocator_destroy when finished.
*/
CFAllocatorRef ;
/**
* Cleans up any resources alloced in aws_wrapped_cf_allocator_new.
*/
void ;
/**
* Returns at least `size` of memory ready for usage. In versions v0.6.8 and prior, this function was allowed to return
* NULL. In later versions, if allocator->mem_acquire() returns NULL, this function will assert and exit. To handle
* conditions where OOM is not a fatal error, allocator->mem_acquire() is responsible for finding/reclaiming/running a
* GC etc...before returning.
*/
void *;
/**
* Allocates a block of memory for an array of num elements, each of them size bytes long, and initializes all its bits
* to zero. In versions v0.6.8 and prior, this function was allowed to return NULL.
* In later versions, if allocator->mem_calloc() returns NULL, this function will assert and exit. To handle
* conditions where OOM is not a fatal error, allocator->mem_calloc() is responsible for finding/reclaiming/running a
* GC etc...before returning.
*/
void *;
/**
* Allocates many chunks of bytes into a single block. Expects to be called with alternating void ** (dest), size_t
* (size). The first void ** will be set to the root of the allocation. Alignment is assumed to be sizeof(intmax_t).
*
* This is useful for allocating structs using the pimpl pattern, as you may allocate the public object and impl object
* in the same contiguous block of memory.
*
* Returns a pointer to the allocation.
*
* In versions v0.6.8 and prior, this function was allowed to return
* NULL. In later versions, if allocator->mem_acquire() returns NULL, this function will assert and exit. To handle
* conditions where OOM is not a fatal error, allocator->mem_acquire() is responsible for finding/reclaiming/running a
* GC etc...before returning.
*/
void *;
/**
* Releases ptr back to whatever allocated it.
* Nothing happens if ptr is NULL.
*/
void ;
/**
* Attempts to adjust the size of the pointed-to memory buffer from oldsize to
* newsize. The pointer (*ptr) may be changed if the memory needs to be
* reallocated.
*
* In versions v0.6.8 and prior, this function was allowed to return
* NULL. In later versions, if allocator->mem_realloc() returns NULL, this function will assert and exit. To handle
* conditions where OOM is not a fatal error, allocator->mem_realloc() is responsible for finding/reclaiming/running a
* GC etc...before returning.
*/
int ;
/*
* Maintainer note: The above function doesn't return the pointer (as with
* standard C realloc) as this pattern becomes error-prone when OOMs occur.
* In particular, we want to avoid losing the old pointer when an OOM condition
* occurs, so we prefer to take the old pointer as an in/out reference argument
* that we can leave unchanged on failure.
*/
;
/*
* Wraps an allocator and tracks all external allocations. If aws_mem_trace_dump() is called
* and there are still allocations active, they will be reported to the aws_logger at TRACE level.
* allocator - The allocator to wrap
* deprecated - Deprecated arg, ignored.
* level - The level to track allocations at
* frames_per_stack is how many frames to store per callstack if AWS_MEMTRACE_STACKS is in use,
* otherwise it is ignored. 8 tends to be a pretty good number balancing storage space vs useful stacks.
* Returns the tracer allocator, which should be used for all allocations that should be tracked.
*/
struct aws_allocator *;
/*
* Unwraps the traced allocator and cleans up the tracer.
* Returns the original allocator
*/
struct aws_allocator *;
/*
* If there are outstanding allocations, dumps them to log, along with any information gathered
* based on the trace level set when aws_mem_trace() was called.
* Should be passed the tracer allocator returned from aws_mem_trace().
*/
void ;
/*
* Returns the current number of bytes in outstanding allocations
*/
size_t ;
/*
* Returns the current number of outstanding allocations
*/
size_t ;
/*
* Creates a new Small Block Allocator which fronts the supplied parent allocator. The SBA will intercept
* and handle small allocs, and will forward anything larger to the parent allocator.
* If multi_threaded is true, the internal allocator will protect its internal data structures with a mutex
*/
struct aws_allocator *;
/*
* Destroys a Small Block Allocator instance and frees its memory to the parent allocator. The parent
* allocator will otherwise be unaffected.
*/
void ;
/*
* Returns the number of bytes currently active in the SBA
*/
size_t ;
/*
* Returns the number of bytes reserved in pages/bins inside the SBA, e.g. the
* current system memory used by the SBA
*/
size_t ;
/*
* Returns the page size that the SBA is using
*/
size_t ;
/* AWS_COMMON_ALLOCATOR_H */