1 | /** @file
|
---|
2 | * IPRT - Memory Management and Manipulation.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2022 Oracle and/or its affiliates.
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox base platform packages, as
|
---|
9 | * available from https://www.virtualbox.org.
|
---|
10 | *
|
---|
11 | * This program is free software; you can redistribute it and/or
|
---|
12 | * modify it under the terms of the GNU General Public License
|
---|
13 | * as published by the Free Software Foundation, in version 3 of the
|
---|
14 | * License.
|
---|
15 | *
|
---|
16 | * This program is distributed in the hope that it will be useful, but
|
---|
17 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
19 | * General Public License for more details.
|
---|
20 | *
|
---|
21 | * You should have received a copy of the GNU General Public License
|
---|
22 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
23 | *
|
---|
24 | * The contents of this file may alternatively be used under the terms
|
---|
25 | * of the Common Development and Distribution License Version 1.0
|
---|
26 | * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
27 | * in the VirtualBox distribution, in which case the provisions of the
|
---|
28 | * CDDL are applicable instead of those of the GPL.
|
---|
29 | *
|
---|
30 | * You may elect to license modified versions of this file under the
|
---|
31 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
32 | *
|
---|
33 | * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
34 | */
|
---|
35 |
|
---|
36 | #ifndef IPRT_INCLUDED_mem_h
|
---|
37 | #define IPRT_INCLUDED_mem_h
|
---|
38 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
39 | # pragma once
|
---|
40 | #endif
|
---|
41 |
|
---|
42 |
|
---|
43 | #include <iprt/cdefs.h>
|
---|
44 | #include <iprt/types.h>
|
---|
45 |
|
---|
46 | #ifdef IPRT_WITH_GCC_SANITIZER
|
---|
47 | # include <sanitizer/lsan_interface.h>
|
---|
48 | #endif
|
---|
49 |
|
---|
50 | #ifdef IN_RC
|
---|
51 | # error "There are no RTMem APIs available Guest Context!"
|
---|
52 | #endif
|
---|
53 |
|
---|
54 |
|
---|
55 | /** @defgroup grp_rt_mem RTMem - Memory Management and Manipulation
|
---|
56 | * @ingroup grp_rt
|
---|
57 | * @{
|
---|
58 | */
|
---|
59 |
|
---|
60 | RT_C_DECLS_BEGIN
|
---|
61 |
|
---|
62 | /** @def RTMEM_ALIGNMENT
|
---|
63 | * The alignment of the memory blocks returned by RTMemAlloc(), RTMemAllocZ(),
|
---|
64 | * RTMemRealloc(), RTMemTmpAlloc() and RTMemTmpAllocZ() for allocations greater
|
---|
65 | * than RTMEM_ALIGNMENT.
|
---|
66 | *
|
---|
67 | * @note This alignment is not forced if the electric fence is active!
|
---|
68 | */
|
---|
69 | #if defined(RT_OS_OS2)
|
---|
70 | # define RTMEM_ALIGNMENT 4
|
---|
71 | #else
|
---|
72 | # define RTMEM_ALIGNMENT 8
|
---|
73 | #endif
|
---|
74 |
|
---|
75 | /** @def RTMEM_TAG
|
---|
76 | * The default allocation tag used by the RTMem allocation APIs.
|
---|
77 | *
|
---|
78 | * When not defined before the inclusion of iprt/mem.h or iprt/memobj.h, this
|
---|
79 | * will default to the pointer to the current file name. The memory API will
|
---|
80 | * make of use of this as pointer to a volatile but read-only string.
|
---|
81 | * The alternative tag includes the line number for a more-detailed analysis.
|
---|
82 | */
|
---|
83 | #ifndef RTMEM_TAG
|
---|
84 | # if 0
|
---|
85 | # define RTMEM_TAG (__FILE__ ":" RT_XSTR(__LINE__))
|
---|
86 | # else
|
---|
87 | # define RTMEM_TAG (__FILE__)
|
---|
88 | # endif
|
---|
89 | #endif
|
---|
90 |
|
---|
91 |
|
---|
92 | /** @name Allocate temporary memory.
|
---|
93 | * @{ */
|
---|
94 | /**
|
---|
95 | * Allocates temporary memory with default tag.
|
---|
96 | *
|
---|
97 | * Temporary memory blocks are used for not too large memory blocks which
|
---|
98 | * are believed not to stick around for too long. Using this API instead
|
---|
99 | * of RTMemAlloc() not only gives the heap manager room for optimization
|
---|
100 | * but makes the code easier to read.
|
---|
101 | *
|
---|
102 | * @returns Pointer to the allocated memory.
|
---|
103 | * @returns NULL on failure, assertion raised in strict builds.
|
---|
104 | * @param cb Size in bytes of the memory block to allocated.
|
---|
105 | */
|
---|
106 | #define RTMemTmpAlloc(cb) RTMemTmpAllocTag((cb), RTMEM_TAG)
|
---|
107 |
|
---|
108 | /**
|
---|
109 | * Allocates temporary memory with custom tag.
|
---|
110 | *
|
---|
111 | * Temporary memory blocks are used for not too large memory blocks which
|
---|
112 | * are believed not to stick around for too long. Using this API instead
|
---|
113 | * of RTMemAlloc() not only gives the heap manager room for optimization
|
---|
114 | * but makes the code easier to read.
|
---|
115 | *
|
---|
116 | * @returns Pointer to the allocated memory.
|
---|
117 | * @returns NULL on failure, assertion raised in strict builds.
|
---|
118 | * @param cb Size in bytes of the memory block to allocated.
|
---|
119 | * @param pszTag Allocation tag used for statistics and such.
|
---|
120 | */
|
---|
121 | RTDECL(void *) RTMemTmpAllocTag(size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
|
---|
122 |
|
---|
123 | /**
|
---|
124 | * Allocates zero'd temporary memory with default tag.
|
---|
125 | *
|
---|
126 | * Same as RTMemTmpAlloc() but the memory will be zero'd.
|
---|
127 | *
|
---|
128 | * @returns Pointer to the allocated memory.
|
---|
129 | * @returns NULL on failure, assertion raised in strict builds.
|
---|
130 | * @param cb Size in bytes of the memory block to allocated.
|
---|
131 | */
|
---|
132 | #define RTMemTmpAllocZ(cb) RTMemTmpAllocZTag((cb), RTMEM_TAG)
|
---|
133 |
|
---|
134 | /**
|
---|
135 | * Allocates zero'd temporary memory with custom tag.
|
---|
136 | *
|
---|
137 | * Same as RTMemTmpAlloc() but the memory will be zero'd.
|
---|
138 | *
|
---|
139 | * @returns Pointer to the allocated memory.
|
---|
140 | * @returns NULL on failure, assertion raised in strict builds.
|
---|
141 | * @param cb Size in bytes of the memory block to allocated.
|
---|
142 | * @param pszTag Allocation tag used for statistics and such.
|
---|
143 | */
|
---|
144 | RTDECL(void *) RTMemTmpAllocZTag(size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
|
---|
145 |
|
---|
146 | /**
|
---|
147 | * Free temporary memory.
|
---|
148 | *
|
---|
149 | * @param pv Pointer to memory block.
|
---|
150 | */
|
---|
151 | RTDECL(void) RTMemTmpFree(void *pv) RT_NO_THROW_PROTO;
|
---|
152 |
|
---|
153 | /**
|
---|
154 | * Clear and free temporary memory.
|
---|
155 | *
|
---|
156 | * This is strongly recommended when the memory being freed holds untrusted data
|
---|
157 | * to help counter heap spraying.
|
---|
158 | *
|
---|
159 | * @param pv Pointer to memory block.
|
---|
160 | * @param cb Size of the memory block.
|
---|
161 | *
|
---|
162 | * @note The memory isn't always filled with zeros, it can be set to a
|
---|
163 | * different value in some configurations.
|
---|
164 | */
|
---|
165 | RTDECL(void) RTMemTmpFreeZ(void *pv, size_t cb) RT_NO_THROW_PROTO;
|
---|
166 |
|
---|
167 | /** @} */
|
---|
168 |
|
---|
169 |
|
---|
170 | /**
|
---|
171 | * Allocates memory with default tag.
|
---|
172 | *
|
---|
173 | * @returns Pointer to the allocated memory.
|
---|
174 | * @returns NULL on failure, assertion raised in strict builds.
|
---|
175 | * @param cb Size in bytes of the memory block to allocated.
|
---|
176 | */
|
---|
177 | #define RTMemAlloc(cb) RTMemAllocTag((cb), RTMEM_TAG)
|
---|
178 |
|
---|
179 | /**
|
---|
180 | * Allocates memory with custom tag.
|
---|
181 | *
|
---|
182 | * @returns Pointer to the allocated memory.
|
---|
183 | * @returns NULL on failure, assertion raised in strict builds.
|
---|
184 | * @param cb Size in bytes of the memory block to allocated.
|
---|
185 | * @param pszTag Allocation tag used for statistics and such.
|
---|
186 | */
|
---|
187 | RTDECL(void *) RTMemAllocTag(size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
|
---|
188 |
|
---|
189 | /**
|
---|
190 | * Allocates zero'd memory with default tag.
|
---|
191 | *
|
---|
192 | * Instead of memset(pv, 0, sizeof()) use this when you want zero'd
|
---|
193 | * memory. This keeps the code smaller and the heap can skip the memset
|
---|
194 | * in about 0.42% of calls :-).
|
---|
195 | *
|
---|
196 | * @returns Pointer to the allocated memory.
|
---|
197 | * @returns NULL on failure.
|
---|
198 | * @param cb Size in bytes of the memory block to allocated.
|
---|
199 | */
|
---|
200 | #define RTMemAllocZ(cb) RTMemAllocZTag((cb), RTMEM_TAG)
|
---|
201 |
|
---|
202 | /**
|
---|
203 | * Allocates zero'd memory with custom tag.
|
---|
204 | *
|
---|
205 | * Instead of memset(pv, 0, sizeof()) use this when you want zero'd
|
---|
206 | * memory. This keeps the code smaller and the heap can skip the memset
|
---|
207 | * in about 0.42% of calls :-).
|
---|
208 | *
|
---|
209 | * @returns Pointer to the allocated memory.
|
---|
210 | * @returns NULL on failure.
|
---|
211 | * @param cb Size in bytes of the memory block to allocated.
|
---|
212 | * @param pszTag Allocation tag used for statistics and such.
|
---|
213 | */
|
---|
214 | RTDECL(void *) RTMemAllocZTag(size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
|
---|
215 |
|
---|
216 | /**
|
---|
217 | * Wrapper around RTMemAlloc for automatically aligning variable sized
|
---|
218 | * allocations so that the various electric fence heaps works correctly.
|
---|
219 | *
|
---|
220 | * @returns See RTMemAlloc.
|
---|
221 | * @param cbUnaligned The unaligned size.
|
---|
222 | */
|
---|
223 | #define RTMemAllocVar(cbUnaligned) RTMemAllocVarTag((cbUnaligned), RTMEM_TAG)
|
---|
224 |
|
---|
225 | /**
|
---|
226 | * Wrapper around RTMemAllocTag for automatically aligning variable sized
|
---|
227 | * allocations so that the various electric fence heaps works correctly.
|
---|
228 | *
|
---|
229 | * @returns See RTMemAlloc.
|
---|
230 | * @param cbUnaligned The unaligned size.
|
---|
231 | * @param pszTag Allocation tag used for statistics and such.
|
---|
232 | */
|
---|
233 | RTDECL(void *) RTMemAllocVarTag(size_t cbUnaligned, const char *pszTag) RT_NO_THROW_PROTO;
|
---|
234 |
|
---|
235 | /**
|
---|
236 | * Wrapper around RTMemAllocZ for automatically aligning variable sized
|
---|
237 | * allocations so that the various electric fence heaps works correctly.
|
---|
238 | *
|
---|
239 | * @returns See RTMemAllocZ.
|
---|
240 | * @param cbUnaligned The unaligned size.
|
---|
241 | */
|
---|
242 | #define RTMemAllocZVar(cbUnaligned) RTMemAllocZVarTag((cbUnaligned), RTMEM_TAG)
|
---|
243 |
|
---|
244 | /**
|
---|
245 | * Wrapper around RTMemAllocZTag for automatically aligning variable sized
|
---|
246 | * allocations so that the various electric fence heaps works correctly.
|
---|
247 | *
|
---|
248 | * @returns See RTMemAllocZ.
|
---|
249 | * @param cbUnaligned The unaligned size.
|
---|
250 | * @param pszTag Allocation tag used for statistics and such.
|
---|
251 | */
|
---|
252 | RTDECL(void *) RTMemAllocZVarTag(size_t cbUnaligned, const char *pszTag) RT_NO_THROW_PROTO;
|
---|
253 |
|
---|
254 | /**
|
---|
255 | * Duplicates a chunk of memory into a new heap block (default tag).
|
---|
256 | *
|
---|
257 | * @returns New heap block with the duplicate data.
|
---|
258 | * @returns NULL if we're out of memory.
|
---|
259 | * @param pvSrc The memory to duplicate.
|
---|
260 | * @param cb The amount of memory to duplicate.
|
---|
261 | */
|
---|
262 | #define RTMemDup(pvSrc, cb) RTMemDupTag((pvSrc), (cb), RTMEM_TAG)
|
---|
263 |
|
---|
264 | /**
|
---|
265 | * Duplicates a chunk of memory into a new heap block (custom tag).
|
---|
266 | *
|
---|
267 | * @returns New heap block with the duplicate data.
|
---|
268 | * @returns NULL if we're out of memory.
|
---|
269 | * @param pvSrc The memory to duplicate.
|
---|
270 | * @param cb The amount of memory to duplicate.
|
---|
271 | * @param pszTag Allocation tag used for statistics and such.
|
---|
272 | */
|
---|
273 | RTDECL(void *) RTMemDupTag(const void *pvSrc, size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
|
---|
274 |
|
---|
275 | /**
|
---|
276 | * Duplicates a chunk of memory into a new heap block with some additional
|
---|
277 | * zeroed memory (default tag).
|
---|
278 | *
|
---|
279 | * @returns New heap block with the duplicate data.
|
---|
280 | * @returns NULL if we're out of memory.
|
---|
281 | * @param pvSrc The memory to duplicate.
|
---|
282 | * @param cbSrc The amount of memory to duplicate.
|
---|
283 | * @param cbExtra The amount of extra memory to allocate and zero.
|
---|
284 | */
|
---|
285 | #define RTMemDupEx(pvSrc, cbSrc, cbExtra) RTMemDupExTag((pvSrc), (cbSrc), (cbExtra), RTMEM_TAG)
|
---|
286 |
|
---|
287 | /**
|
---|
288 | * Duplicates a chunk of memory into a new heap block with some additional
|
---|
289 | * zeroed memory (default tag).
|
---|
290 | *
|
---|
291 | * @returns New heap block with the duplicate data.
|
---|
292 | * @returns NULL if we're out of memory.
|
---|
293 | * @param pvSrc The memory to duplicate.
|
---|
294 | * @param cbSrc The amount of memory to duplicate.
|
---|
295 | * @param cbExtra The amount of extra memory to allocate and zero.
|
---|
296 | * @param pszTag Allocation tag used for statistics and such.
|
---|
297 | */
|
---|
298 | RTDECL(void *) RTMemDupExTag(const void *pvSrc, size_t cbSrc, size_t cbExtra, const char *pszTag) RT_NO_THROW_PROTO;
|
---|
299 |
|
---|
300 | /**
|
---|
301 | * Reallocates memory with default tag.
|
---|
302 | *
|
---|
303 | * @returns Pointer to the allocated memory.
|
---|
304 | * @returns NULL on failure.
|
---|
305 | * @param pvOld The memory block to reallocate.
|
---|
306 | * @param cbNew The new block size (in bytes).
|
---|
307 | */
|
---|
308 | #define RTMemRealloc(pvOld, cbNew) RTMemReallocTag((pvOld), (cbNew), RTMEM_TAG)
|
---|
309 |
|
---|
310 | /**
|
---|
311 | * Reallocates memory with custom tag.
|
---|
312 | *
|
---|
313 | * @returns Pointer to the allocated memory.
|
---|
314 | * @returns NULL on failure.
|
---|
315 | * @param pvOld The memory block to reallocate.
|
---|
316 | * @param cbNew The new block size (in bytes).
|
---|
317 | * @param pszTag Allocation tag used for statistics and such.
|
---|
318 | */
|
---|
319 | RTDECL(void *) RTMemReallocTag(void *pvOld, size_t cbNew, const char *pszTag) RT_NO_THROW_PROTO;
|
---|
320 |
|
---|
321 | /**
|
---|
322 | * Reallocates memory with default tag, initializing any new space to zero.
|
---|
323 | *
|
---|
324 | * @returns Pointer to the allocated memory.
|
---|
325 | * @returns NULL on failure.
|
---|
326 | * @param pvOld The memory block to reallocate.
|
---|
327 | * @param cbOld The old block size (in bytes).
|
---|
328 | * @param cbNew The new block size (in bytes).
|
---|
329 | */
|
---|
330 | #define RTMemReallocZ(pvOld, cbOld, cbNew) RTMemReallocZTag((pvOld), (cbOld), (cbNew), RTMEM_TAG)
|
---|
331 |
|
---|
332 | /**
|
---|
333 | * Reallocates memory with custom tag, initializing any new space to zero.
|
---|
334 | *
|
---|
335 | * @returns Pointer to the allocated memory.
|
---|
336 | * @returns NULL on failure.
|
---|
337 | * @param pvOld The memory block to reallocate.
|
---|
338 | * @param cbOld The old block size (in bytes).
|
---|
339 | * @param cbNew The new block size (in bytes).
|
---|
340 | * @param pszTag Allocation tag used for statistics and such.
|
---|
341 | */
|
---|
342 | RTDECL(void *) RTMemReallocZTag(void *pvOld, size_t cbOld, size_t cbNew, const char *pszTag) RT_NO_THROW_PROTO;
|
---|
343 |
|
---|
344 | /**
|
---|
345 | * Frees memory.
|
---|
346 | *
|
---|
347 | * @param pv Pointer to memory block.
|
---|
348 | */
|
---|
349 | RTDECL(void) RTMemFree(void *pv) RT_NO_THROW_PROTO;
|
---|
350 |
|
---|
351 | /**
|
---|
352 | * Clears and frees memory.
|
---|
353 | *
|
---|
354 | * This is strongly recommended when the memory being freed holds untrusted data
|
---|
355 | * to help counter heap spraying.
|
---|
356 | *
|
---|
357 | * @param pv Pointer to memory block.
|
---|
358 | * @param cb The size of the allocation.
|
---|
359 | *
|
---|
360 | * @note The memory isn't always filled with zeros, it can be set to a
|
---|
361 | * different value in some configurations.
|
---|
362 | */
|
---|
363 | RTDECL(void) RTMemFreeZ(void *pv, size_t cb) RT_NO_THROW_PROTO;
|
---|
364 |
|
---|
365 |
|
---|
366 |
|
---|
367 | /** @name RTR0MemAllocEx and RTR0MemAllocExTag flags.
|
---|
368 | * @{ */
|
---|
369 | /** The returned memory should be zeroed. */
|
---|
370 | #define RTMEMALLOCEX_FLAGS_ZEROED RT_BIT(0)
|
---|
371 | /** It must be load code into the returned memory block and execute it. */
|
---|
372 | #define RTMEMALLOCEX_FLAGS_EXEC RT_BIT(1)
|
---|
373 | /** Allocation from any context.
|
---|
374 | * Will return VERR_NOT_SUPPORTED if not supported. */
|
---|
375 | #define RTMEMALLOCEX_FLAGS_ANY_CTX_ALLOC RT_BIT(2)
|
---|
376 | /** Allocate the memory such that it can be freed from any context.
|
---|
377 | * Will return VERR_NOT_SUPPORTED if not supported. */
|
---|
378 | #define RTMEMALLOCEX_FLAGS_ANY_CTX_FREE RT_BIT(3)
|
---|
379 | /** Allocate and free from any context.
|
---|
380 | * Will return VERR_NOT_SUPPORTED if not supported. */
|
---|
381 | #define RTMEMALLOCEX_FLAGS_ANY_CTX (RTMEMALLOCEX_FLAGS_ANY_CTX_ALLOC | RTMEMALLOCEX_FLAGS_ANY_CTX_FREE)
|
---|
382 | /** Reachable by 16-bit address.
|
---|
383 | * Will return VERR_NOT_SUPPORTED if not supported. */
|
---|
384 | #define RTMEMALLOCEX_FLAGS_16BIT_REACH RT_BIT(4)
|
---|
385 | /** Reachable by 32-bit address.
|
---|
386 | * Will return VERR_NOT_SUPPORTED if not supported. */
|
---|
387 | #define RTMEMALLOCEX_FLAGS_32BIT_REACH RT_BIT(5)
|
---|
388 | /** Mask of valid flags. */
|
---|
389 | #define RTMEMALLOCEX_FLAGS_VALID_MASK UINT32_C(0x0000003f)
|
---|
390 | /** Mask of valid flags for ring-0. */
|
---|
391 | #define RTMEMALLOCEX_FLAGS_VALID_MASK_R0 UINT32_C(0x0000000f)
|
---|
392 | /** @} */
|
---|
393 |
|
---|
394 | /**
|
---|
395 | * Extended heap allocation API, default tag.
|
---|
396 | *
|
---|
397 | * @returns IPRT status code.
|
---|
398 | * @retval VERR_NO_MEMORY if we're out of memory.
|
---|
399 | * @retval VERR_NO_EXEC_MEMORY if we're out of executable memory.
|
---|
400 | * @retval VERR_NOT_SUPPORTED if any of the specified flags are unsupported.
|
---|
401 | *
|
---|
402 | * @param cb The amount of memory to allocate.
|
---|
403 | * @param cbAlignment The alignment requirements. Use 0 to indicate
|
---|
404 | * default alignment.
|
---|
405 | * @param fFlags A combination of the RTMEMALLOCEX_FLAGS_XXX
|
---|
406 | * defines.
|
---|
407 | * @param ppv Where to return the memory.
|
---|
408 | */
|
---|
409 | #define RTMemAllocEx(cb, cbAlignment, fFlags, ppv) RTMemAllocExTag((cb), (cbAlignment), (fFlags), RTMEM_TAG, (ppv))
|
---|
410 |
|
---|
411 | /**
|
---|
412 | * Extended heap allocation API, custom tag.
|
---|
413 | *
|
---|
414 | * Depending on the implementation, using this function may add extra overhead,
|
---|
415 | * so use the simpler APIs where ever possible.
|
---|
416 | *
|
---|
417 | * @returns IPRT status code.
|
---|
418 | * @retval VERR_NO_MEMORY if we're out of memory.
|
---|
419 | * @retval VERR_NO_EXEC_MEMORY if we're out of executable memory.
|
---|
420 | * @retval VERR_NOT_SUPPORTED if any of the specified flags are unsupported.
|
---|
421 | *
|
---|
422 | * @param cb The amount of memory to allocate.
|
---|
423 | * @param cbAlignment The alignment requirements. Use 0 to indicate
|
---|
424 | * default alignment.
|
---|
425 | * @param fFlags A combination of the RTMEMALLOCEX_FLAGS_XXX
|
---|
426 | * defines.
|
---|
427 | * @param pszTag The tag.
|
---|
428 | * @param ppv Where to return the memory.
|
---|
429 | */
|
---|
430 | RTDECL(int) RTMemAllocExTag(size_t cb, size_t cbAlignment, uint32_t fFlags, const char *pszTag, void **ppv) RT_NO_THROW_PROTO;
|
---|
431 |
|
---|
432 | /**
|
---|
433 | * For freeing memory allocated by RTMemAllocEx or RTMemAllocExTag.
|
---|
434 | *
|
---|
435 | * @param pv What to free, NULL is fine.
|
---|
436 | * @param cb The amount of allocated memory.
|
---|
437 | */
|
---|
438 | RTDECL(void) RTMemFreeEx(void *pv, size_t cb) RT_NO_THROW_PROTO;
|
---|
439 |
|
---|
440 |
|
---|
441 |
|
---|
442 | /**
|
---|
443 | * Allocates memory which may contain code (default tag).
|
---|
444 | *
|
---|
445 | * @returns Pointer to the allocated memory.
|
---|
446 | * @returns NULL on failure.
|
---|
447 | * @param cb Size in bytes of the memory block to allocate.
|
---|
448 | */
|
---|
449 | #define RTMemExecAlloc(cb) RTMemExecAllocTag((cb), RTMEM_TAG)
|
---|
450 |
|
---|
451 | /**
|
---|
452 | * Allocates memory which may contain code (custom tag).
|
---|
453 | *
|
---|
454 | * @returns Pointer to the allocated memory.
|
---|
455 | * @returns NULL on failure.
|
---|
456 | * @param cb Size in bytes of the memory block to allocate.
|
---|
457 | * @param pszTag Allocation tag used for statistics and such.
|
---|
458 | */
|
---|
459 | RTDECL(void *) RTMemExecAllocTag(size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
|
---|
460 |
|
---|
461 | /**
|
---|
462 | * Free executable/read/write memory allocated by RTMemExecAlloc().
|
---|
463 | *
|
---|
464 | * @param pv Pointer to memory block.
|
---|
465 | * @param cb The allocation size.
|
---|
466 | */
|
---|
467 | RTDECL(void) RTMemExecFree(void *pv, size_t cb) RT_NO_THROW_PROTO;
|
---|
468 |
|
---|
469 | /**
|
---|
470 | * Allocate page aligned memory with default tag.
|
---|
471 | *
|
---|
472 | * @returns Pointer to the allocated memory.
|
---|
473 | * @returns NULL if we're out of memory.
|
---|
474 | * @param cb Size of the memory block. Will be rounded up to page size.
|
---|
475 | */
|
---|
476 | #define RTMemPageAlloc(cb) RTMemPageAllocTag((cb), RTMEM_TAG)
|
---|
477 |
|
---|
478 | /**
|
---|
479 | * Allocate page aligned memory with custom tag.
|
---|
480 | *
|
---|
481 | * @returns Pointer to the allocated memory.
|
---|
482 | * @returns NULL if we're out of memory.
|
---|
483 | * @param cb Size of the memory block. Will be rounded up to page size.
|
---|
484 | * @param pszTag Allocation tag used for statistics and such.
|
---|
485 | */
|
---|
486 | RTDECL(void *) RTMemPageAllocTag(size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
|
---|
487 |
|
---|
488 | /**
|
---|
489 | * Allocate zero'd page aligned memory with default tag.
|
---|
490 | *
|
---|
491 | * @returns Pointer to the allocated memory.
|
---|
492 | * @returns NULL if we're out of memory.
|
---|
493 | * @param cb Size of the memory block. Will be rounded up to page size.
|
---|
494 | */
|
---|
495 | #define RTMemPageAllocZ(cb) RTMemPageAllocZTag((cb), RTMEM_TAG)
|
---|
496 |
|
---|
497 | /**
|
---|
498 | * Allocate zero'd page aligned memory with custom tag.
|
---|
499 | *
|
---|
500 | * @returns Pointer to the allocated memory.
|
---|
501 | * @returns NULL if we're out of memory.
|
---|
502 | * @param cb Size of the memory block. Will be rounded up to page size.
|
---|
503 | * @param pszTag Allocation tag used for statistics and such.
|
---|
504 | */
|
---|
505 | RTDECL(void *) RTMemPageAllocZTag(size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
|
---|
506 |
|
---|
507 | /**
|
---|
508 | * Allocate page aligned memory with default tag, extended version.
|
---|
509 | *
|
---|
510 | * @returns Pointer to the allocated memory.
|
---|
511 | * @returns NULL if we're out of memory.
|
---|
512 | * @param cb Size of the memory block. Will be rounded up to page size.
|
---|
513 | * @param fFlags RTMEMPAGEALLOC_F_XXX.
|
---|
514 | */
|
---|
515 | #define RTMemPageAllocEx(cb, fFlags) RTMemPageAllocExTag((cb), (fFlags), RTMEM_TAG)
|
---|
516 |
|
---|
517 | /**
|
---|
518 | * Allocate page aligned memory with custom tag, extended version.
|
---|
519 | *
|
---|
520 | * @returns Pointer to the allocated memory.
|
---|
521 | * @returns NULL if we're out of memory.
|
---|
522 | * @param cb Size of the memory block. Will be rounded up to page size.
|
---|
523 | * @param fFlags RTMEMPAGEALLOC_F_XXX.
|
---|
524 | * @param pszTag Allocation tag used for statistics and such.
|
---|
525 | */
|
---|
526 | RTDECL(void *) RTMemPageAllocExTag(size_t cb, uint32_t fFlags, const char *pszTag) RT_NO_THROW_PROTO;
|
---|
527 |
|
---|
528 | /** @name RTMEMPAGEALLOC_F_XXX - flags for RTMemPageAllocEx() and RTMemPageAllocExTag()
|
---|
529 | * @{ */
|
---|
530 | /** Zero the allocation. */
|
---|
531 | #define RTMEMPAGEALLOC_F_ZERO RT_BIT_32(0)
|
---|
532 | /** Try lock the allocation (failure ignored). */
|
---|
533 | #define RTMEMPAGEALLOC_F_ADVISE_LOCKED RT_BIT_32(1)
|
---|
534 | /** Try prevent the memory from ending up in a dump/core. */
|
---|
535 | #define RTMEMPAGEALLOC_F_ADVISE_NO_DUMP RT_BIT_32(2)
|
---|
536 | /** Valid bit mask. */
|
---|
537 | #define RTMEMPAGEALLOC_F_VALID_MASK UINT32_C(0x00000007)
|
---|
538 | /** @} */
|
---|
539 |
|
---|
540 | /**
|
---|
541 | * Free a memory block allocated with RTMemPageAlloc() or RTMemPageAllocZ().
|
---|
542 | *
|
---|
543 | * @param pv Pointer to the block as it was returned by the allocation function.
|
---|
544 | * NULL will be ignored.
|
---|
545 | * @param cb The allocation size. Will be rounded up to page size.
|
---|
546 | * Ignored if @a pv is NULL.
|
---|
547 | */
|
---|
548 | RTDECL(void) RTMemPageFree(void *pv, size_t cb) RT_NO_THROW_PROTO;
|
---|
549 |
|
---|
550 | /** Page level protection flags for RTMemProtect().
|
---|
551 | * @{
|
---|
552 | */
|
---|
553 | /** No access at all. */
|
---|
554 | #define RTMEM_PROT_NONE 0
|
---|
555 | /** Read access. */
|
---|
556 | #define RTMEM_PROT_READ 1
|
---|
557 | /** Write access. */
|
---|
558 | #define RTMEM_PROT_WRITE 2
|
---|
559 | /** Execute access. */
|
---|
560 | #define RTMEM_PROT_EXEC 4
|
---|
561 | /** @} */
|
---|
562 |
|
---|
563 | /**
|
---|
564 | * Change the page level protection of a memory region.
|
---|
565 | *
|
---|
566 | * @returns iprt status code.
|
---|
567 | * @param pv Start of the region. Will be rounded down to nearest page boundary.
|
---|
568 | * @param cb Size of the region. Will be rounded up to the nearest page boundary.
|
---|
569 | * @param fProtect The new protection, a combination of the RTMEM_PROT_* defines.
|
---|
570 | */
|
---|
571 | RTDECL(int) RTMemProtect(void *pv, size_t cb, unsigned fProtect) RT_NO_THROW_PROTO;
|
---|
572 |
|
---|
573 | /**
|
---|
574 | * Goes thru some pains to make sure the specified memory block is thoroughly
|
---|
575 | * scrambled.
|
---|
576 | *
|
---|
577 | * @param pv The start of the memory block.
|
---|
578 | * @param cb The size of the memory block.
|
---|
579 | * @param cMinPasses The minimum number of passes to make.
|
---|
580 | */
|
---|
581 | RTDECL(void) RTMemWipeThoroughly(void *pv, size_t cb, size_t cMinPasses) RT_NO_THROW_PROTO;
|
---|
582 |
|
---|
583 |
|
---|
584 | /** @def RTMEM_WILL_LEAK
|
---|
585 | * Macro for hinting that a memory allocation @a a_pv will leak.
|
---|
586 | *
|
---|
587 | * @note This shall only be used in code that doesn't allocate the object.
|
---|
588 | * Code allocating memory knowing it will leak shall start the allocation
|
---|
589 | * tag string with 'will-leak:'.
|
---|
590 | */
|
---|
591 | /** @def RTMEM_MAY_LEAK
|
---|
592 | * Macro for hinting that a memory allocation @a a_pv may leak.
|
---|
593 | *
|
---|
594 | * @note This shall only be used in code that doesn't allocate the object.
|
---|
595 | * Code allocating memory knowing it may leak shall start the allocation
|
---|
596 | * tag string with 'may-leak:'.
|
---|
597 | */
|
---|
598 | #ifdef IPRT_WITH_GCC_SANITIZER
|
---|
599 | # define RTMEM_WILL_LEAK(a_pv) __lsan_ignore_object(a_pv)
|
---|
600 | # define RTMEM_MAY_LEAK(a_pv) __lsan_ignore_object(a_pv)
|
---|
601 | #else
|
---|
602 | # define RTMEM_WILL_LEAK(a_pv) do { } while (0)
|
---|
603 | # define RTMEM_MAY_LEAK(a_pv) do { } while (0)
|
---|
604 | #endif
|
---|
605 |
|
---|
606 |
|
---|
607 | /** @def RTMEM_IMPLEMENT_NEW_AND_DELETE
|
---|
608 | * Provides a new and delete implementation to a class using IPRT's RTMem
|
---|
609 | * allocator.
|
---|
610 | */
|
---|
611 | #if !defined(RTMEM_WRAP_SOME_NEW_AND_DELETE_TO_EF) || defined(RTMEM_NO_WRAP_SOME_NEW_AND_DELETE_TO_EF)
|
---|
612 | # ifdef RT_EXCEPTIONS_ENABLED
|
---|
613 | # define RTMEM_IMPLEMENT_NEW_AND_DELETE() \
|
---|
614 | void *operator new(size_t cb) RT_THROW(std::bad_alloc) \
|
---|
615 | { \
|
---|
616 | void *pv = RTMemAlloc(cb); \
|
---|
617 | if (RT_LIKELY(pv)) \
|
---|
618 | return pv; \
|
---|
619 | throw std::bad_alloc(); \
|
---|
620 | } \
|
---|
621 | void *operator new(size_t cb, const std::nothrow_t ¬hrow_constant) RT_NO_THROW_DEF \
|
---|
622 | { \
|
---|
623 | NOREF(nothrow_constant); \
|
---|
624 | return RTMemAlloc(cb); \
|
---|
625 | } \
|
---|
626 | void *operator new(size_t cb, void *pvBuf) RT_NO_THROW_DEF \
|
---|
627 | { \
|
---|
628 | NOREF(cb); \
|
---|
629 | return pvBuf; \
|
---|
630 | } \
|
---|
631 | void *operator new[](size_t cb) RT_THROW(std::bad_alloc) \
|
---|
632 | { \
|
---|
633 | void *pv = RTMemAlloc(cb); \
|
---|
634 | if (RT_LIKELY(pv)) \
|
---|
635 | return pv; \
|
---|
636 | throw std::bad_alloc(); \
|
---|
637 | } \
|
---|
638 | void *operator new[](size_t cb, const std::nothrow_t ¬hrow_constant) RT_NO_THROW_DEF \
|
---|
639 | { \
|
---|
640 | NOREF(nothrow_constant); \
|
---|
641 | return RTMemAlloc(cb); \
|
---|
642 | } \
|
---|
643 | \
|
---|
644 | void operator delete(void *pv) RT_NO_THROW_DEF \
|
---|
645 | { \
|
---|
646 | RTMemFree(pv); \
|
---|
647 | } \
|
---|
648 | void operator delete(void *pv, const std::nothrow_t ¬hrow_constant) RT_NO_THROW_DEF \
|
---|
649 | { \
|
---|
650 | NOREF(nothrow_constant); \
|
---|
651 | RTMemFree(pv); \
|
---|
652 | } \
|
---|
653 | void operator delete[](void *pv) RT_NO_THROW_DEF \
|
---|
654 | { \
|
---|
655 | RTMemFree(pv); \
|
---|
656 | } \
|
---|
657 | void operator delete[](void *pv, const std::nothrow_t ¬hrow_constant) RT_NO_THROW_DEF \
|
---|
658 | { \
|
---|
659 | NOREF(nothrow_constant); \
|
---|
660 | RTMemFree(pv); \
|
---|
661 | } \
|
---|
662 | \
|
---|
663 | typedef int UsingIprtNewAndDeleteOperators
|
---|
664 | # else /* !RT_EXCEPTIONS_ENABLED */
|
---|
665 | # define RTMEM_IMPLEMENT_NEW_AND_DELETE() \
|
---|
666 | void *operator new(size_t cb) \
|
---|
667 | { \
|
---|
668 | return RTMemAlloc(cb); \
|
---|
669 | } \
|
---|
670 | void *operator new(size_t cb, const std::nothrow_t ¬hrow_constant) \
|
---|
671 | { \
|
---|
672 | NOREF(nothrow_constant); \
|
---|
673 | return RTMemAlloc(cb); \
|
---|
674 | } \
|
---|
675 | void *operator new(size_t cb, void *pvBuf) RT_NO_THROW_DEF \
|
---|
676 | { \
|
---|
677 | NOREF(cb); \
|
---|
678 | return pvBuf; \
|
---|
679 | } \
|
---|
680 | void *operator new[](size_t cb) \
|
---|
681 | { \
|
---|
682 | return RTMemAlloc(cb); \
|
---|
683 | } \
|
---|
684 | void *operator new[](size_t cb, const std::nothrow_t ¬hrow_constant) \
|
---|
685 | { \
|
---|
686 | NOREF(nothrow_constant); \
|
---|
687 | return RTMemAlloc(cb); \
|
---|
688 | } \
|
---|
689 | \
|
---|
690 | void operator delete(void *pv) \
|
---|
691 | { \
|
---|
692 | RTMemFree(pv); \
|
---|
693 | } \
|
---|
694 | void operator delete(void *pv, const std::nothrow_t ¬hrow_constant) \
|
---|
695 | { \
|
---|
696 | NOREF(nothrow_constant); \
|
---|
697 | RTMemFree(pv); \
|
---|
698 | } \
|
---|
699 | void operator delete[](void *pv) \
|
---|
700 | { \
|
---|
701 | RTMemFree(pv); \
|
---|
702 | } \
|
---|
703 | void operator delete[](void *pv, const std::nothrow_t ¬hrow_constant) \
|
---|
704 | { \
|
---|
705 | NOREF(nothrow_constant); \
|
---|
706 | RTMemFree(pv); \
|
---|
707 | } \
|
---|
708 | \
|
---|
709 | typedef int UsingIprtNewAndDeleteOperators
|
---|
710 | # endif /* !RT_EXCEPTIONS_ENABLED */
|
---|
711 | #else /* defined(RTMEM_WRAP_SOME_NEW_AND_DELETE_TO_EF) && !defined(RTMEM_NO_WRAP_SOME_NEW_AND_DELETE_TO_EF) */
|
---|
712 | # define RTMEM_IMPLEMENT_NEW_AND_DELETE() RTMEMEF_NEW_AND_DELETE_OPERATORS()
|
---|
713 | #endif /* defined(RTMEM_WRAP_SOME_NEW_AND_DELETE_TO_EF) && !defined(RTMEM_NO_WRAP_SOME_NEW_AND_DELETE_TO_EF) */
|
---|
714 |
|
---|
715 |
|
---|
716 | #ifdef IN_RING0
|
---|
717 |
|
---|
718 | /**
|
---|
719 | * Allocates physical contiguous memory (below 4GB).
|
---|
720 | * The allocation is page aligned and the content is undefined.
|
---|
721 | *
|
---|
722 | * @returns Pointer to the memory block. This is page aligned.
|
---|
723 | * @param pPhys Where to store the physical address.
|
---|
724 | * @param cb The allocation size in bytes. This is always
|
---|
725 | * rounded up to PAGE_SIZE.
|
---|
726 | */
|
---|
727 | RTR0DECL(void *) RTMemContAlloc(PRTCCPHYS pPhys, size_t cb) RT_NO_THROW_PROTO;
|
---|
728 |
|
---|
729 | /**
|
---|
730 | * Frees memory allocated ysing RTMemContAlloc().
|
---|
731 | *
|
---|
732 | * @param pv Pointer to return from RTMemContAlloc().
|
---|
733 | * @param cb The cb parameter passed to RTMemContAlloc().
|
---|
734 | */
|
---|
735 | RTR0DECL(void) RTMemContFree(void *pv, size_t cb) RT_NO_THROW_PROTO;
|
---|
736 |
|
---|
737 | /**
|
---|
738 | * Copy memory from an user mode buffer into a kernel buffer.
|
---|
739 | *
|
---|
740 | * @retval VINF_SUCCESS on success.
|
---|
741 | * @retval VERR_ACCESS_DENIED on error.
|
---|
742 | *
|
---|
743 | * @param pvDst The kernel mode destination address.
|
---|
744 | * @param R3PtrSrc The user mode source address.
|
---|
745 | * @param cb The number of bytes to copy.
|
---|
746 | */
|
---|
747 | RTR0DECL(int) RTR0MemUserCopyFrom(void *pvDst, RTR3PTR R3PtrSrc, size_t cb);
|
---|
748 |
|
---|
749 | /**
|
---|
750 | * Copy memory from a kernel buffer into a user mode one.
|
---|
751 | *
|
---|
752 | * @retval VINF_SUCCESS on success.
|
---|
753 | * @retval VERR_ACCESS_DENIED on error.
|
---|
754 | *
|
---|
755 | * @param R3PtrDst The user mode destination address.
|
---|
756 | * @param pvSrc The kernel mode source address.
|
---|
757 | * @param cb The number of bytes to copy.
|
---|
758 | */
|
---|
759 | RTR0DECL(int) RTR0MemUserCopyTo(RTR3PTR R3PtrDst, void const *pvSrc, size_t cb);
|
---|
760 |
|
---|
761 | /**
|
---|
762 | * Tests if the specified address is in the user addressable range.
|
---|
763 | *
|
---|
764 | * This function does not check whether the memory at that address is accessible
|
---|
765 | * or anything of that sort, only if the address it self is in the user mode
|
---|
766 | * range.
|
---|
767 | *
|
---|
768 | * @returns true if it's in the user addressable range. false if not.
|
---|
769 | * @param R3Ptr The user mode pointer to test.
|
---|
770 | *
|
---|
771 | * @remarks Some systems may have overlapping kernel and user address ranges.
|
---|
772 | * One prominent example of this is the x86 version of Mac OS X. Use
|
---|
773 | * RTR0MemAreKrnlAndUsrDifferent() to check.
|
---|
774 | */
|
---|
775 | RTR0DECL(bool) RTR0MemUserIsValidAddr(RTR3PTR R3Ptr);
|
---|
776 |
|
---|
777 | /**
|
---|
778 | * Tests if the specified address is in the kernel mode range.
|
---|
779 | *
|
---|
780 | * This function does not check whether the memory at that address is accessible
|
---|
781 | * or anything of that sort, only if the address it self is in the kernel mode
|
---|
782 | * range.
|
---|
783 | *
|
---|
784 | * @returns true if it's in the kernel range. false if not.
|
---|
785 | * @param pv The alleged kernel mode pointer.
|
---|
786 | *
|
---|
787 | * @remarks Some systems may have overlapping kernel and user address ranges.
|
---|
788 | * One prominent example of this is the x86 version of Mac OS X. Use
|
---|
789 | * RTR0MemAreKrnlAndUsrDifferent() to check.
|
---|
790 | */
|
---|
791 | RTR0DECL(bool) RTR0MemKernelIsValidAddr(void *pv);
|
---|
792 |
|
---|
793 | /**
|
---|
794 | * Are user mode and kernel mode address ranges distinctly different.
|
---|
795 | *
|
---|
796 | * This determines whether RTR0MemKernelIsValidAddr and RTR0MemUserIsValidAddr
|
---|
797 | * can be used for deciding whether some arbitrary address is a user mode or a
|
---|
798 | * kernel mode one.
|
---|
799 | *
|
---|
800 | * @returns true if they are, false if not.
|
---|
801 | */
|
---|
802 | RTR0DECL(bool) RTR0MemAreKrnlAndUsrDifferent(void);
|
---|
803 |
|
---|
804 | /**
|
---|
805 | * Copy memory from an potentially unsafe kernel mode location and into a safe
|
---|
806 | * (kernel) buffer.
|
---|
807 | *
|
---|
808 | * @retval VINF_SUCCESS on success.
|
---|
809 | * @retval VERR_ACCESS_DENIED on error.
|
---|
810 | * @retval VERR_NOT_SUPPORTED if not (yet) supported.
|
---|
811 | *
|
---|
812 | * @param pvDst The destination address (safe).
|
---|
813 | * @param pvSrc The source address (potentially unsafe).
|
---|
814 | * @param cb The number of bytes to copy.
|
---|
815 | */
|
---|
816 | RTR0DECL(int) RTR0MemKernelCopyFrom(void *pvDst, void const *pvSrc, size_t cb);
|
---|
817 |
|
---|
818 | /**
|
---|
819 | * Copy from a safe (kernel) buffer and to a potentially unsafe kenrel mode
|
---|
820 | * location.
|
---|
821 | *
|
---|
822 | * @retval VINF_SUCCESS on success.
|
---|
823 | * @retval VERR_ACCESS_DENIED on error.
|
---|
824 | * @retval VERR_NOT_SUPPORTED if not (yet) supported.
|
---|
825 | *
|
---|
826 | * @param pvDst The destination address (potentially unsafe).
|
---|
827 | * @param pvSrc The source address (safe).
|
---|
828 | * @param cb The number of bytes to copy.
|
---|
829 | */
|
---|
830 | RTR0DECL(int) RTR0MemKernelCopyTo(void *pvDst, void const *pvSrc, size_t cb);
|
---|
831 |
|
---|
832 | #endif /* IN_RING0 */
|
---|
833 |
|
---|
834 |
|
---|
835 | /** @name Electrical Fence Version of some APIs.
|
---|
836 | * @{
|
---|
837 | */
|
---|
838 |
|
---|
839 | /**
|
---|
840 | * Same as RTMemTmpAllocTag() except that it's fenced.
|
---|
841 | *
|
---|
842 | * @returns Pointer to the allocated memory.
|
---|
843 | * @returns NULL on failure.
|
---|
844 | * @param cb Size in bytes of the memory block to allocate.
|
---|
845 | * @param pszTag Allocation tag used for statistics and such.
|
---|
846 | * @param SRC_POS The source position where call is being made from.
|
---|
847 | * Use RT_SRC_POS when possible. Optional.
|
---|
848 | */
|
---|
849 | RTDECL(void *) RTMemEfTmpAlloc(size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
|
---|
850 |
|
---|
851 | /**
|
---|
852 | * Same as RTMemTmpAllocZTag() except that it's fenced.
|
---|
853 | *
|
---|
854 | * @returns Pointer to the allocated memory.
|
---|
855 | * @returns NULL on failure.
|
---|
856 | * @param cb Size in bytes of the memory block to allocate.
|
---|
857 | * @param pszTag Allocation tag used for statistics and such.
|
---|
858 | * @param SRC_POS The source position where call is being made from. Use
|
---|
859 | * RT_SRC_POS when possible. Optional.
|
---|
860 | */
|
---|
861 | RTDECL(void *) RTMemEfTmpAllocZ(size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
|
---|
862 |
|
---|
863 | /**
|
---|
864 | * Same as RTMemTmpFree() except that it's for fenced memory.
|
---|
865 | *
|
---|
866 | * @param pv Pointer to memory block.
|
---|
867 | * @param SRC_POS The source position where call is being made from. Use
|
---|
868 | * RT_SRC_POS when possible. Optional.
|
---|
869 | */
|
---|
870 | RTDECL(void) RTMemEfTmpFree(void *pv, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
|
---|
871 |
|
---|
872 | /**
|
---|
873 | * Same as RTMemTmpFreeZ() except that it's for fenced memory.
|
---|
874 | *
|
---|
875 | * @param pv Pointer to memory block.
|
---|
876 | * @param cb Size of the memory block.
|
---|
877 | * @param SRC_POS The source position where call is being made from. Use
|
---|
878 | * RT_SRC_POS when possible. Optional.
|
---|
879 | */
|
---|
880 | RTDECL(void) RTMemEfTmpFreeZ(void *pv, size_t cb, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
|
---|
881 |
|
---|
882 | /**
|
---|
883 | * Same as RTMemAllocTag() except that it's fenced.
|
---|
884 | *
|
---|
885 | * @returns Pointer to the allocated memory. Free with RTMemEfFree().
|
---|
886 | * @returns NULL on failure.
|
---|
887 | * @param cb Size in bytes of the memory block to allocate.
|
---|
888 | * @param pszTag Allocation tag used for statistics and such.
|
---|
889 | * @param SRC_POS The source position where call is being made from. Use
|
---|
890 | * RT_SRC_POS when possible. Optional.
|
---|
891 | */
|
---|
892 | RTDECL(void *) RTMemEfAlloc(size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
|
---|
893 |
|
---|
894 | /**
|
---|
895 | * Same as RTMemAllocZTag() except that it's fenced.
|
---|
896 | *
|
---|
897 | * @returns Pointer to the allocated memory.
|
---|
898 | * @returns NULL on failure.
|
---|
899 | * @param cb Size in bytes of the memory block to allocate.
|
---|
900 | * @param pszTag Allocation tag used for statistics and such.
|
---|
901 | * @param SRC_POS The source position where call is being made from. Use
|
---|
902 | * RT_SRC_POS when possible. Optional.
|
---|
903 | */
|
---|
904 | RTDECL(void *) RTMemEfAllocZ(size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
|
---|
905 |
|
---|
906 | /**
|
---|
907 | * Same as RTMemAllocVarTag() except that it's fenced.
|
---|
908 | *
|
---|
909 | * @returns Pointer to the allocated memory. Free with RTMemEfFree().
|
---|
910 | * @returns NULL on failure.
|
---|
911 | * @param cbUnaligned Size in bytes of the memory block to allocate.
|
---|
912 | * @param pszTag Allocation tag used for statistics and such.
|
---|
913 | * @param SRC_POS The source position where call is being made from. Use
|
---|
914 | * RT_SRC_POS when possible. Optional.
|
---|
915 | */
|
---|
916 | RTDECL(void *) RTMemEfAllocVar(size_t cbUnaligned, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
|
---|
917 |
|
---|
918 | /**
|
---|
919 | * Same as RTMemAllocZVarTag() except that it's fenced.
|
---|
920 | *
|
---|
921 | * @returns Pointer to the allocated memory.
|
---|
922 | * @returns NULL on failure.
|
---|
923 | * @param cbUnaligned Size in bytes of the memory block to allocate.
|
---|
924 | * @param pszTag Allocation tag used for statistics and such.
|
---|
925 | * @param SRC_POS The source position where call is being made from. Use
|
---|
926 | * RT_SRC_POS when possible. Optional.
|
---|
927 | */
|
---|
928 | RTDECL(void *) RTMemEfAllocZVar(size_t cbUnaligned, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
|
---|
929 |
|
---|
930 | /**
|
---|
931 | * Same as RTMemReallocTag() except that it's fenced.
|
---|
932 | *
|
---|
933 | * @returns Pointer to the allocated memory.
|
---|
934 | * @returns NULL on failure.
|
---|
935 | * @param pvOld The memory block to reallocate.
|
---|
936 | * @param cbNew The new block size (in bytes).
|
---|
937 | * @param pszTag Allocation tag used for statistics and such.
|
---|
938 | * @param SRC_POS The source position where call is being made from. Use
|
---|
939 | * RT_SRC_POS when possible. Optional.
|
---|
940 | */
|
---|
941 | RTDECL(void *) RTMemEfRealloc(void *pvOld, size_t cbNew, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
|
---|
942 |
|
---|
943 | /**
|
---|
944 | * Same as RTMemReallocZTag() except that it's fenced.
|
---|
945 | *
|
---|
946 | * @returns Pointer to the allocated memory.
|
---|
947 | * @returns NULL on failure.
|
---|
948 | * @param pvOld The memory block to reallocate.
|
---|
949 | * @param cbOld The old block size (in bytes).
|
---|
950 | * @param cbNew The new block size (in bytes).
|
---|
951 | * @param pszTag Allocation tag used for statistics and such.
|
---|
952 | * @param SRC_POS The source position where call is being made from. Use
|
---|
953 | * RT_SRC_POS when possible. Optional.
|
---|
954 | */
|
---|
955 | RTDECL(void *) RTMemEfReallocZ(void *pvOld, size_t cbOld, size_t cbNew, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
|
---|
956 |
|
---|
957 | /**
|
---|
958 | * Free memory allocated by any of the RTMemEf* allocators.
|
---|
959 | *
|
---|
960 | * @param pv Pointer to memory block.
|
---|
961 | * @param SRC_POS The source position where call is being made from. Use
|
---|
962 | * RT_SRC_POS when possible. Optional.
|
---|
963 | */
|
---|
964 | RTDECL(void) RTMemEfFree(void *pv, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
|
---|
965 |
|
---|
966 | /**
|
---|
967 | * Clear and free memory allocated by any of the RTMemEf* allocators.
|
---|
968 | *
|
---|
969 | * @param pv Pointer to memory block.
|
---|
970 | * @param cb Size of the allocation.
|
---|
971 | * @param SRC_POS The source position where call is being made from. Use
|
---|
972 | * RT_SRC_POS when possible. Optional.
|
---|
973 | */
|
---|
974 | RTDECL(void) RTMemEfFreeZ(void *pv, size_t cb, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
|
---|
975 |
|
---|
976 | /**
|
---|
977 | * Same as RTMemDupTag() except that it's fenced.
|
---|
978 | *
|
---|
979 | * @returns New heap block with the duplicate data.
|
---|
980 | * @returns NULL if we're out of memory.
|
---|
981 | * @param pvSrc The memory to duplicate.
|
---|
982 | * @param cb The amount of memory to duplicate.
|
---|
983 | * @param pszTag Allocation tag used for statistics and such.
|
---|
984 | * @param SRC_POS The source position where call is being made from. Use
|
---|
985 | * RT_SRC_POS when possible. Optional.
|
---|
986 | */
|
---|
987 | RTDECL(void *) RTMemEfDup(const void *pvSrc, size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
|
---|
988 |
|
---|
989 | /**
|
---|
990 | * Same as RTMemEfDupExTag except that it's fenced.
|
---|
991 | *
|
---|
992 | * @returns New heap block with the duplicate data.
|
---|
993 | * @returns NULL if we're out of memory.
|
---|
994 | * @param pvSrc The memory to duplicate.
|
---|
995 | * @param cbSrc The amount of memory to duplicate.
|
---|
996 | * @param cbExtra The amount of extra memory to allocate and zero.
|
---|
997 | * @param pszTag Allocation tag used for statistics and such.
|
---|
998 | * @param SRC_POS The source position where call is being made from. Use
|
---|
999 | * RT_SRC_POS when possible. Optional.
|
---|
1000 | */
|
---|
1001 | RTDECL(void *) RTMemEfDupEx(const void *pvSrc, size_t cbSrc, size_t cbExtra, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
|
---|
1002 |
|
---|
1003 | /** @def RTMEM_WRAP_SOME_NEW_AND_DELETE_TO_EF
|
---|
1004 | * Define RTMEM_WRAP_SOME_NEW_AND_DELETE_TO_EF to enable electric fence new and
|
---|
1005 | * delete operators for classes which uses the RTMEMEF_NEW_AND_DELETE_OPERATORS
|
---|
1006 | * macro.
|
---|
1007 | */
|
---|
1008 | /** @def RTMEMEF_NEW_AND_DELETE_OPERATORS
|
---|
1009 | * Defines the electric fence new and delete operators for a class when
|
---|
1010 | * RTMEM_WRAP_SOME_NEW_AND_DELETE_TO_EF is define.
|
---|
1011 | */
|
---|
1012 | /** @def RTR0MEMEF_NEW_AND_DELETE_OPERATORS_IOKIT
|
---|
1013 | * Defines the electric fence new and delete operators for an IOKit class when
|
---|
1014 | * RTMEM_WRAP_SOME_NEW_AND_DELETE_TO_EF is define.
|
---|
1015 | *
|
---|
1016 | * This differs from RTMEMEF_NEW_AND_DELETE_OPERATORS in that the memory we
|
---|
1017 | * allocate is initialized to zero. It is also assuming we don't have nothrow
|
---|
1018 | * variants and exceptions, so fewer variations.
|
---|
1019 | */
|
---|
1020 | #if defined(RTMEM_WRAP_SOME_NEW_AND_DELETE_TO_EF) && !defined(RTMEM_NO_WRAP_SOME_NEW_AND_DELETE_TO_EF)
|
---|
1021 | # if defined(RT_EXCEPTIONS_ENABLED)
|
---|
1022 | # define RTMEMEF_NEW_AND_DELETE_OPERATORS() \
|
---|
1023 | void *operator new(size_t cb) RT_THROW(std::bad_alloc) \
|
---|
1024 | { \
|
---|
1025 | void *pv = RTMemEfAlloc(cb, RTMEM_TAG, RT_SRC_POS); \
|
---|
1026 | if (RT_LIKELY(pv)) \
|
---|
1027 | return pv; \
|
---|
1028 | throw std::bad_alloc(); \
|
---|
1029 | } \
|
---|
1030 | void *operator new(size_t cb, const std::nothrow_t ¬hrow_constant) RT_NO_THROW_DEF \
|
---|
1031 | { \
|
---|
1032 | NOREF(nothrow_constant); \
|
---|
1033 | return RTMemEfAlloc(cb, RTMEM_TAG, RT_SRC_POS); \
|
---|
1034 | } \
|
---|
1035 | void *operator new(size_t cb, void *pvBuf) RT_NO_THROW_DEF \
|
---|
1036 | { \
|
---|
1037 | NOREF(cb); \
|
---|
1038 | return pvBuf; \
|
---|
1039 | } \
|
---|
1040 | void *operator new[](size_t cb) RT_THROW(std::bad_alloc) \
|
---|
1041 | { \
|
---|
1042 | void *pv = RTMemEfAlloc(cb, RTMEM_TAG, RT_SRC_POS); \
|
---|
1043 | if (RT_LIKELY(pv)) \
|
---|
1044 | return pv; \
|
---|
1045 | throw std::bad_alloc(); \
|
---|
1046 | } \
|
---|
1047 | void *operator new[](size_t cb, const std::nothrow_t ¬hrow_constant) RT_NO_THROW_DEF \
|
---|
1048 | { \
|
---|
1049 | NOREF(nothrow_constant); \
|
---|
1050 | return RTMemEfAlloc(cb, RTMEM_TAG, RT_SRC_POS); \
|
---|
1051 | } \
|
---|
1052 | \
|
---|
1053 | void operator delete(void *pv) RT_NO_THROW_DEF \
|
---|
1054 | { \
|
---|
1055 | RTMemEfFree(pv, RT_SRC_POS); \
|
---|
1056 | } \
|
---|
1057 | void operator delete(void *pv, const std::nothrow_t ¬hrow_constant) RT_NO_THROW_DEF \
|
---|
1058 | { \
|
---|
1059 | NOREF(nothrow_constant); \
|
---|
1060 | RTMemEfFree(pv, RT_SRC_POS); \
|
---|
1061 | } \
|
---|
1062 | void operator delete[](void *pv) RT_NO_THROW_DEF \
|
---|
1063 | { \
|
---|
1064 | RTMemEfFree(pv, RT_SRC_POS); \
|
---|
1065 | } \
|
---|
1066 | void operator delete[](void *pv, const std::nothrow_t ¬hrow_constant) RT_NO_THROW_DEF \
|
---|
1067 | { \
|
---|
1068 | NOREF(nothrow_constant); \
|
---|
1069 | RTMemEfFree(pv, RT_SRC_POS); \
|
---|
1070 | } \
|
---|
1071 | \
|
---|
1072 | typedef int UsingElectricNewAndDeleteOperators
|
---|
1073 | # else
|
---|
1074 | # define RTMEMEF_NEW_AND_DELETE_OPERATORS() \
|
---|
1075 | void *operator new(size_t cb) \
|
---|
1076 | { \
|
---|
1077 | return RTMemEfAlloc(cb, RTMEM_TAG, RT_SRC_POS); \
|
---|
1078 | } \
|
---|
1079 | void *operator new(size_t cb, const std::nothrow_t ¬hrow_constant) \
|
---|
1080 | { \
|
---|
1081 | NOREF(nothrow_constant); \
|
---|
1082 | return RTMemEfAlloc(cb, RTMEM_TAG, RT_SRC_POS); \
|
---|
1083 | } \
|
---|
1084 | void *operator new(size_t cb, void *pvBuf) RT_NO_THROW_DEF \
|
---|
1085 | { \
|
---|
1086 | NOREF(cb); \
|
---|
1087 | return pvBuf; \
|
---|
1088 | } \
|
---|
1089 | void *operator new[](size_t cb) \
|
---|
1090 | { \
|
---|
1091 | return RTMemEfAlloc(cb, RTMEM_TAG, RT_SRC_POS); \
|
---|
1092 | } \
|
---|
1093 | void *operator new[](size_t cb, const std::nothrow_t ¬hrow_constant) \
|
---|
1094 | { \
|
---|
1095 | NOREF(nothrow_constant); \
|
---|
1096 | return RTMemEfAlloc(cb, RTMEM_TAG, RT_SRC_POS); \
|
---|
1097 | } \
|
---|
1098 | \
|
---|
1099 | void operator delete(void *pv) \
|
---|
1100 | { \
|
---|
1101 | RTMemEfFree(pv, RT_SRC_POS); \
|
---|
1102 | } \
|
---|
1103 | void operator delete(void *pv, const std::nothrow_t ¬hrow_constant) \
|
---|
1104 | { \
|
---|
1105 | NOREF(nothrow_constant); \
|
---|
1106 | RTMemEfFree(pv, RT_SRC_POS); \
|
---|
1107 | } \
|
---|
1108 | void operator delete[](void *pv) \
|
---|
1109 | { \
|
---|
1110 | RTMemEfFree(pv, RT_SRC_POS); \
|
---|
1111 | } \
|
---|
1112 | void operator delete[](void *pv, const std::nothrow_t ¬hrow_constant) \
|
---|
1113 | { \
|
---|
1114 | NOREF(nothrow_constant); \
|
---|
1115 | RTMemEfFree(pv, RT_SRC_POS); \
|
---|
1116 | } \
|
---|
1117 | \
|
---|
1118 | typedef int UsingElectricNewAndDeleteOperators
|
---|
1119 | # endif
|
---|
1120 | # define RTR0MEMEF_NEW_AND_DELETE_OPERATORS_IOKIT() \
|
---|
1121 | void *operator new(size_t cb) \
|
---|
1122 | { \
|
---|
1123 | return RTMemEfAllocZ(cb, RTMEM_TAG, RT_SRC_POS); \
|
---|
1124 | } \
|
---|
1125 | void *operator new[](size_t cb) \
|
---|
1126 | { \
|
---|
1127 | return RTMemEfAllocZ(cb, RTMEM_TAG, RT_SRC_POS); \
|
---|
1128 | } \
|
---|
1129 | \
|
---|
1130 | void operator delete(void *pv) \
|
---|
1131 | { \
|
---|
1132 | RTMemEfFree(pv, RT_SRC_POS); \
|
---|
1133 | } \
|
---|
1134 | void operator delete[](void *pv) \
|
---|
1135 | { \
|
---|
1136 | RTMemEfFree(pv, RT_SRC_POS); \
|
---|
1137 | } \
|
---|
1138 | \
|
---|
1139 | typedef int UsingElectricNewAndDeleteOperators
|
---|
1140 | #else
|
---|
1141 | # define RTMEMEF_NEW_AND_DELETE_OPERATORS() \
|
---|
1142 | typedef int UsingDefaultNewAndDeleteOperators
|
---|
1143 | # define RTR0MEMEF_NEW_AND_DELETE_OPERATORS_IOKIT() \
|
---|
1144 | typedef int UsingDefaultNewAndDeleteOperators
|
---|
1145 | #endif
|
---|
1146 | #ifdef DOXYGEN_RUNNING
|
---|
1147 | # define RTMEM_WRAP_SOME_NEW_AND_DELETE_TO_EF
|
---|
1148 | #endif
|
---|
1149 |
|
---|
1150 | /** @def RTMEM_WRAP_TO_EF_APIS
|
---|
1151 | * Define RTMEM_WRAP_TO_EF_APIS to wrap RTMem APIs to RTMemEf APIs.
|
---|
1152 | */
|
---|
1153 | #if defined(RTMEM_WRAP_TO_EF_APIS) && !defined(RTMEM_NO_WRAP_TO_EF_APIS) \
|
---|
1154 | && ( defined(IN_RING3) || ( defined(IN_RING0) && !defined(IN_RING0_AGNOSTIC) && (defined(RT_OS_DARWIN) || 0) ) )
|
---|
1155 | # define RTMemTmpAllocTag(cb, pszTag) RTMemEfTmpAlloc((cb), (pszTag), RT_SRC_POS)
|
---|
1156 | # define RTMemTmpAllocZTag(cb, pszTag) RTMemEfTmpAllocZ((cb), (pszTag), RT_SRC_POS)
|
---|
1157 | # define RTMemTmpFree(pv) RTMemEfTmpFree((pv), RT_SRC_POS)
|
---|
1158 | # define RTMemTmpFreeZ(pv, cb) RTMemEfTmpFreeZ((pv), (cb), RT_SRC_POS)
|
---|
1159 | # define RTMemAllocTag(cb, pszTag) RTMemEfAlloc((cb), (pszTag), RT_SRC_POS)
|
---|
1160 | # define RTMemAllocZTag(cb, pszTag) RTMemEfAllocZ((cb), (pszTag), RT_SRC_POS)
|
---|
1161 | # define RTMemAllocVarTag(cbUnaligned, pszTag) RTMemEfAllocVar((cbUnaligned), (pszTag), RT_SRC_POS)
|
---|
1162 | # define RTMemAllocZVarTag(cbUnaligned, pszTag) RTMemEfAllocZVar((cbUnaligned), (pszTag), RT_SRC_POS)
|
---|
1163 | # define RTMemReallocTag(pvOld, cbNew, pszTag) RTMemEfRealloc((pvOld), (cbNew), (pszTag), RT_SRC_POS)
|
---|
1164 | # define RTMemReallocZTag(pvOld, cbOld, cbNew, pszTag) RTMemEfReallocZ((pvOld), (cbOld), (cbNew), (pszTag), RT_SRC_POS)
|
---|
1165 | # define RTMemFree(pv) RTMemEfFree((pv), RT_SRC_POS)
|
---|
1166 | # define RTMemFreeZ(pv, cb) RTMemEfFreeZ((pv), (cb), RT_SRC_POS)
|
---|
1167 | # define RTMemDupTag(pvSrc, cb, pszTag) RTMemEfDup((pvSrc), (cb), (pszTag), RT_SRC_POS)
|
---|
1168 | # define RTMemDupExTag(pvSrc, cbSrc, cbExtra, pszTag) RTMemEfDupEx((pvSrc), (cbSrc), (cbExtra), (pszTag), RT_SRC_POS)
|
---|
1169 | #endif
|
---|
1170 | #ifdef DOXYGEN_RUNNING
|
---|
1171 | # define RTMEM_WRAP_TO_EF_APIS
|
---|
1172 | #endif
|
---|
1173 |
|
---|
1174 | /**
|
---|
1175 | * Fenced drop-in replacement for RTMemTmpAllocTag.
|
---|
1176 | * @copydoc RTMemTmpAllocTag
|
---|
1177 | */
|
---|
1178 | RTDECL(void *) RTMemEfTmpAllocNP(size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
|
---|
1179 |
|
---|
1180 | /**
|
---|
1181 | * Fenced drop-in replacement for RTMemTmpAllocZTag.
|
---|
1182 | * @copydoc RTMemTmpAllocZTag
|
---|
1183 | */
|
---|
1184 | RTDECL(void *) RTMemEfTmpAllocZNP(size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
|
---|
1185 |
|
---|
1186 | /**
|
---|
1187 | * Fenced drop-in replacement for RTMemTmpFree.
|
---|
1188 | * @copydoc RTMemTmpFree
|
---|
1189 | */
|
---|
1190 | RTDECL(void) RTMemEfTmpFreeNP(void *pv) RT_NO_THROW_PROTO;
|
---|
1191 |
|
---|
1192 | /**
|
---|
1193 | * Fenced drop-in replacement for RTMemTmpFreeZ.
|
---|
1194 | * @copydoc RTMemTmpFreeZ
|
---|
1195 | */
|
---|
1196 | RTDECL(void) RTMemEfTmpFreeZNP(void *pv, size_t cb) RT_NO_THROW_PROTO;
|
---|
1197 |
|
---|
1198 | /**
|
---|
1199 | * Fenced drop-in replacement for RTMemAllocTag.
|
---|
1200 | * @copydoc RTMemAllocTag
|
---|
1201 | */
|
---|
1202 | RTDECL(void *) RTMemEfAllocNP(size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
|
---|
1203 |
|
---|
1204 | /**
|
---|
1205 | * Fenced drop-in replacement for RTMemAllocZTag.
|
---|
1206 | * @copydoc RTMemAllocZTag
|
---|
1207 | */
|
---|
1208 | RTDECL(void *) RTMemEfAllocZNP(size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
|
---|
1209 |
|
---|
1210 | /**
|
---|
1211 | * Fenced drop-in replacement for RTMemAllocVarTag
|
---|
1212 | * @copydoc RTMemAllocVarTag
|
---|
1213 | */
|
---|
1214 | RTDECL(void *) RTMemEfAllocVarNP(size_t cbUnaligned, const char *pszTag) RT_NO_THROW_PROTO;
|
---|
1215 |
|
---|
1216 | /**
|
---|
1217 | * Fenced drop-in replacement for RTMemAllocZVarTag.
|
---|
1218 | * @copydoc RTMemAllocZVarTag
|
---|
1219 | */
|
---|
1220 | RTDECL(void *) RTMemEfAllocZVarNP(size_t cbUnaligned, const char *pszTag) RT_NO_THROW_PROTO;
|
---|
1221 |
|
---|
1222 | /**
|
---|
1223 | * Fenced drop-in replacement for RTMemReallocTag.
|
---|
1224 | * @copydoc RTMemReallocTag
|
---|
1225 | */
|
---|
1226 | RTDECL(void *) RTMemEfReallocNP(void *pvOld, size_t cbNew, const char *pszTag) RT_NO_THROW_PROTO;
|
---|
1227 |
|
---|
1228 | /**
|
---|
1229 | * Fenced drop-in replacement for RTMemReallocZTag.
|
---|
1230 | * @copydoc RTMemReallocZTag
|
---|
1231 | */
|
---|
1232 | RTDECL(void *) RTMemEfReallocZNP(void *pvOld, size_t cbOld, size_t cbNew, const char *pszTag) RT_NO_THROW_PROTO;
|
---|
1233 |
|
---|
1234 | /**
|
---|
1235 | * Fenced drop-in replacement for RTMemFree.
|
---|
1236 | * @copydoc RTMemFree
|
---|
1237 | */
|
---|
1238 | RTDECL(void) RTMemEfFreeNP(void *pv) RT_NO_THROW_PROTO;
|
---|
1239 |
|
---|
1240 | /**
|
---|
1241 | * Fenced drop-in replacement for RTMemFreeZ.
|
---|
1242 | * @copydoc RTMemFreeZ
|
---|
1243 | */
|
---|
1244 | RTDECL(void) RTMemEfFreeZNP(void *pv, size_t cb) RT_NO_THROW_PROTO;
|
---|
1245 |
|
---|
1246 | /**
|
---|
1247 | * Fenced drop-in replacement for RTMemDupExTag.
|
---|
1248 | * @copydoc RTMemDupTag
|
---|
1249 | */
|
---|
1250 | RTDECL(void *) RTMemEfDupNP(const void *pvSrc, size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
|
---|
1251 |
|
---|
1252 | /**
|
---|
1253 | * Fenced drop-in replacement for RTMemDupExTag.
|
---|
1254 | * @copydoc RTMemDupExTag
|
---|
1255 | */
|
---|
1256 | RTDECL(void *) RTMemEfDupExNP(const void *pvSrc, size_t cbSrc, size_t cbExtra, const char *pszTag) RT_NO_THROW_PROTO;
|
---|
1257 |
|
---|
1258 | /** @} */
|
---|
1259 |
|
---|
1260 | RT_C_DECLS_END
|
---|
1261 |
|
---|
1262 | /** @} */
|
---|
1263 |
|
---|
1264 |
|
---|
1265 | #endif /* !IPRT_INCLUDED_mem_h */
|
---|
1266 |
|
---|