GuestHost/installation/VBoxWinDrvInst.cpp: Try harder if DiInstallDriverW() returns...
[vbox.git] / include / iprt / mem.h
blob6b377b957eb98a6724ed037c3a2c6068a7cd489a
1 /** @file
2 * IPRT - Memory Management and Manipulation.
3 */
5 /*
6 * Copyright (C) 2006-2024 Oracle and/or its affiliates.
8 * This file is part of VirtualBox base platform packages, as
9 * available from https://www.virtualbox.org.
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.
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.
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>.
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.
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.
33 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
36 #ifndef IPRT_INCLUDED_mem_h
37 #define IPRT_INCLUDED_mem_h
38 #ifndef RT_WITHOUT_PRAGMA_ONCE
39 # pragma once
40 #endif
43 #include <iprt/cdefs.h>
44 #include <iprt/types.h>
46 #ifdef IPRT_WITH_GCC_SANITIZER
47 # include <sanitizer/lsan_interface.h>
48 #endif
50 #ifdef IN_RC
51 # error "There are no RTMem APIs available Guest Context!"
52 #endif
55 /** @defgroup grp_rt_mem RTMem - Memory Management and Manipulation
56 * @ingroup grp_rt
57 * @{
60 RT_C_DECLS_BEGIN
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.
67 * @note This alignment is not forced if the electric fence is active!
69 #if defined(RT_OS_OS2)
70 # define RTMEM_ALIGNMENT 4
71 #else
72 # define RTMEM_ALIGNMENT 8
73 #endif
75 /** @def RTMEM_TAG
76 * The default allocation tag used by the RTMem allocation APIs.
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.
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
92 /** @name Allocate temporary memory.
93 * @{ */
94 /**
95 * Allocates temporary memory with default tag.
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.
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.
106 #define RTMemTmpAlloc(cb) RTMemTmpAllocTag((cb), RTMEM_TAG)
109 * Allocates temporary memory with custom tag.
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.
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.
121 RTDECL(void *) RTMemTmpAllocTag(size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
124 * Allocates zero'd temporary memory with default tag.
126 * Same as RTMemTmpAlloc() but the memory will be zero'd.
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.
132 #define RTMemTmpAllocZ(cb) RTMemTmpAllocZTag((cb), RTMEM_TAG)
135 * Allocates zero'd temporary memory with custom tag.
137 * Same as RTMemTmpAlloc() but the memory will be zero'd.
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.
144 RTDECL(void *) RTMemTmpAllocZTag(size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
147 * Free temporary memory.
149 * @param pv Pointer to memory block.
151 RTDECL(void) RTMemTmpFree(void *pv) RT_NO_THROW_PROTO;
154 * Clear and free temporary memory.
156 * This is strongly recommended when the memory being freed holds untrusted data
157 * to help counter heap spraying.
159 * @param pv Pointer to memory block.
160 * @param cb Size of the memory block.
162 * @note The memory isn't always filled with zeros, it can be set to a
163 * different value in some configurations.
165 RTDECL(void) RTMemTmpFreeZ(void *pv, size_t cb) RT_NO_THROW_PROTO;
167 /** @} */
171 * Allocates memory with default tag.
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.
177 #define RTMemAlloc(cb) RTMemAllocTag((cb), RTMEM_TAG)
180 * Allocates memory with custom tag.
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.
187 RTDECL(void *) RTMemAllocTag(size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
190 * Allocates zero'd memory with default tag.
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 :-).
196 * @returns Pointer to the allocated memory.
197 * @returns NULL on failure.
198 * @param cb Size in bytes of the memory block to allocated.
200 #define RTMemAllocZ(cb) RTMemAllocZTag((cb), RTMEM_TAG)
203 * Allocates zero'd memory with custom tag.
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 :-).
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.
214 RTDECL(void *) RTMemAllocZTag(size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
217 * Wrapper around RTMemAlloc for automatically aligning variable sized
218 * allocations so that the various electric fence heaps works correctly.
220 * @returns See RTMemAlloc.
221 * @param cbUnaligned The unaligned size.
223 #define RTMemAllocVar(cbUnaligned) RTMemAllocVarTag((cbUnaligned), RTMEM_TAG)
226 * Wrapper around RTMemAllocTag for automatically aligning variable sized
227 * allocations so that the various electric fence heaps works correctly.
229 * @returns See RTMemAlloc.
230 * @param cbUnaligned The unaligned size.
231 * @param pszTag Allocation tag used for statistics and such.
233 RTDECL(void *) RTMemAllocVarTag(size_t cbUnaligned, const char *pszTag) RT_NO_THROW_PROTO;
236 * Wrapper around RTMemAllocZ for automatically aligning variable sized
237 * allocations so that the various electric fence heaps works correctly.
239 * @returns See RTMemAllocZ.
240 * @param cbUnaligned The unaligned size.
242 #define RTMemAllocZVar(cbUnaligned) RTMemAllocZVarTag((cbUnaligned), RTMEM_TAG)
245 * Wrapper around RTMemAllocZTag for automatically aligning variable sized
246 * allocations so that the various electric fence heaps works correctly.
248 * @returns See RTMemAllocZ.
249 * @param cbUnaligned The unaligned size.
250 * @param pszTag Allocation tag used for statistics and such.
252 RTDECL(void *) RTMemAllocZVarTag(size_t cbUnaligned, const char *pszTag) RT_NO_THROW_PROTO;
255 * Duplicates a chunk of memory into a new heap block (default tag).
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.
262 #define RTMemDup(pvSrc, cb) RTMemDupTag((pvSrc), (cb), RTMEM_TAG)
265 * Duplicates a chunk of memory into a new heap block (custom tag).
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.
273 RTDECL(void *) RTMemDupTag(const void *pvSrc, size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
276 * Duplicates a chunk of memory into a new heap block with some additional
277 * zeroed memory (default tag).
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.
285 #define RTMemDupEx(pvSrc, cbSrc, cbExtra) RTMemDupExTag((pvSrc), (cbSrc), (cbExtra), RTMEM_TAG)
288 * Duplicates a chunk of memory into a new heap block with some additional
289 * zeroed memory (default tag).
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.
298 RTDECL(void *) RTMemDupExTag(const void *pvSrc, size_t cbSrc, size_t cbExtra, const char *pszTag) RT_NO_THROW_PROTO;
301 * Reallocates memory with default tag.
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).
308 #define RTMemRealloc(pvOld, cbNew) RTMemReallocTag((pvOld), (cbNew), RTMEM_TAG)
311 * Reallocates memory with custom tag.
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.
319 RTDECL(void *) RTMemReallocTag(void *pvOld, size_t cbNew, const char *pszTag) RT_NO_THROW_PROTO;
322 * Reallocates memory with default tag, initializing any new space to zero.
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).
330 #define RTMemReallocZ(pvOld, cbOld, cbNew) RTMemReallocZTag((pvOld), (cbOld), (cbNew), RTMEM_TAG)
333 * Reallocates memory with custom tag, initializing any new space to zero.
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.
342 RTDECL(void *) RTMemReallocZTag(void *pvOld, size_t cbOld, size_t cbNew, const char *pszTag) RT_NO_THROW_PROTO;
345 * Frees memory.
347 * @param pv Pointer to memory block.
349 RTDECL(void) RTMemFree(void *pv) RT_NO_THROW_PROTO;
352 * Clears and frees memory.
354 * This is strongly recommended when the memory being freed holds untrusted data
355 * to help counter heap spraying.
357 * @param pv Pointer to memory block.
358 * @param cb The size of the allocation.
360 * @note The memory isn't always filled with zeros, it can be set to a
361 * different value in some configurations.
363 RTDECL(void) RTMemFreeZ(void *pv, size_t cb) RT_NO_THROW_PROTO;
367 /** @name RTR0MemAllocEx and RTR0MemAllocExTag flags.
368 * @{ */
369 /** The returned memory should be zeroed. */
370 #define RTMEMALLOCEX_FLAGS_ZEROED RT_BIT(0)
371 /** Allocate memory that can be executed.
372 * @note Only supported in ring-3 for now, use RTR0MemObjAllocPage w/ @a
373 * fExecutable = @c true for ring-0. */
374 #define RTMEMALLOCEX_FLAGS_EXEC RT_BIT(1)
375 /** Allocation from any context.
376 * Will return VERR_NOT_SUPPORTED if not supported. */
377 #define RTMEMALLOCEX_FLAGS_ANY_CTX_ALLOC RT_BIT(2)
378 /** Allocate the memory such that it can be freed from any context.
379 * Will return VERR_NOT_SUPPORTED if not supported. */
380 #define RTMEMALLOCEX_FLAGS_ANY_CTX_FREE RT_BIT(3)
381 /** Allocate and free from any context.
382 * Will return VERR_NOT_SUPPORTED if not supported. */
383 #define RTMEMALLOCEX_FLAGS_ANY_CTX (RTMEMALLOCEX_FLAGS_ANY_CTX_ALLOC | RTMEMALLOCEX_FLAGS_ANY_CTX_FREE)
384 /** Reachable by 16-bit address.
385 * Will return VERR_NOT_SUPPORTED if not supported. */
386 #define RTMEMALLOCEX_FLAGS_16BIT_REACH RT_BIT(4)
387 /** Reachable by 32-bit address.
388 * Will return VERR_NOT_SUPPORTED if not supported. */
389 #define RTMEMALLOCEX_FLAGS_32BIT_REACH RT_BIT(5)
390 /** Mask of valid flags. */
391 #define RTMEMALLOCEX_FLAGS_VALID_MASK UINT32_C(0x0000003f)
392 /** Mask of valid flags for ring-0. */
393 #define RTMEMALLOCEX_FLAGS_VALID_MASK_R0 UINT32_C(0x0000000f)
394 /** @} */
397 * Extended heap allocation API, default tag.
399 * @returns IPRT status code.
400 * @retval VERR_NO_MEMORY if we're out of memory.
401 * @retval VERR_NO_EXEC_MEMORY if we're out of executable memory.
402 * @retval VERR_NOT_SUPPORTED if any of the specified flags are unsupported.
404 * @param cb The amount of memory to allocate.
405 * @param cbAlignment The alignment requirements. Use 0 to indicate
406 * default alignment.
407 * @param fFlags A combination of the RTMEMALLOCEX_FLAGS_XXX
408 * defines.
409 * @param ppv Where to return the memory.
411 #define RTMemAllocEx(cb, cbAlignment, fFlags, ppv) RTMemAllocExTag((cb), (cbAlignment), (fFlags), RTMEM_TAG, (ppv))
414 * Extended heap allocation API, custom tag.
416 * Depending on the implementation, using this function may add extra overhead,
417 * so use the simpler APIs where ever possible.
419 * @returns IPRT status code.
420 * @retval VERR_NO_MEMORY if we're out of memory.
421 * @retval VERR_NO_EXEC_MEMORY if we're out of executable memory.
422 * @retval VERR_NOT_SUPPORTED if any of the specified flags are unsupported.
424 * @param cb The amount of memory to allocate.
425 * @param cbAlignment The alignment requirements. Use 0 to indicate
426 * default alignment.
427 * @param fFlags A combination of the RTMEMALLOCEX_FLAGS_XXX
428 * defines.
429 * @param pszTag The tag.
430 * @param ppv Where to return the memory.
432 RTDECL(int) RTMemAllocExTag(size_t cb, size_t cbAlignment, uint32_t fFlags, const char *pszTag, void **ppv) RT_NO_THROW_PROTO;
435 * For freeing memory allocated by RTMemAllocEx or RTMemAllocExTag.
437 * @param pv What to free, NULL is fine.
438 * @param cb The amount of allocated memory.
440 RTDECL(void) RTMemFreeEx(void *pv, size_t cb) RT_NO_THROW_PROTO;
443 * Allocate page aligned memory with default tag.
445 * @returns Pointer to the allocated memory.
446 * @returns NULL if we're out of memory.
447 * @param cb Size of the memory block. Will be rounded up to page size.
449 #define RTMemPageAlloc(cb) RTMemPageAllocTag((cb), RTMEM_TAG)
452 * Allocate page aligned memory with custom tag.
454 * @returns Pointer to the allocated memory.
455 * @returns NULL if we're out of memory.
456 * @param cb Size of the memory block. Will be rounded up to page size.
457 * @param pszTag Allocation tag used for statistics and such.
459 RTDECL(void *) RTMemPageAllocTag(size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
462 * Allocate zero'd page aligned memory with default tag.
464 * @returns Pointer to the allocated memory.
465 * @returns NULL if we're out of memory.
466 * @param cb Size of the memory block. Will be rounded up to page size.
468 #define RTMemPageAllocZ(cb) RTMemPageAllocZTag((cb), RTMEM_TAG)
471 * Allocate zero'd page aligned memory with custom tag.
473 * @returns Pointer to the allocated memory.
474 * @returns NULL if we're out of memory.
475 * @param cb Size of the memory block. Will be rounded up to page size.
476 * @param pszTag Allocation tag used for statistics and such.
478 RTDECL(void *) RTMemPageAllocZTag(size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
481 * Allocate page aligned memory with default tag, extended version.
483 * @returns Pointer to the allocated memory.
484 * @returns NULL if we're out of memory.
485 * @param cb Size of the memory block. Will be rounded up to page size.
486 * @param fFlags RTMEMPAGEALLOC_F_XXX.
488 #define RTMemPageAllocEx(cb, fFlags) RTMemPageAllocExTag((cb), (fFlags), RTMEM_TAG)
491 * Allocate page aligned memory with custom tag, extended version.
493 * @returns Pointer to the allocated memory.
494 * @returns NULL if we're out of memory.
495 * @param cb Size of the memory block. Will be rounded up to page size.
496 * @param fFlags RTMEMPAGEALLOC_F_XXX.
497 * @param pszTag Allocation tag used for statistics and such.
499 RTDECL(void *) RTMemPageAllocExTag(size_t cb, uint32_t fFlags, const char *pszTag) RT_NO_THROW_PROTO;
501 /** @name RTMEMPAGEALLOC_F_XXX - flags for RTMemPageAllocEx() and RTMemPageAllocExTag()
502 * @{ */
503 /** Zero the allocation. */
504 #define RTMEMPAGEALLOC_F_ZERO RT_BIT_32(0)
505 /** Try lock the allocation (failure ignored). */
506 #define RTMEMPAGEALLOC_F_ADVISE_LOCKED RT_BIT_32(1)
507 /** Try prevent the memory from ending up in a dump/core. */
508 #define RTMEMPAGEALLOC_F_ADVISE_NO_DUMP RT_BIT_32(2)
509 /** Allocate pages that are readable, writeable and executable.
510 * @note This may fail on some platforms for security policy reasons. */
511 #define RTMEMPAGEALLOC_F_EXECUTABLE RT_BIT_32(3)
512 /** Valid bit mask. */
513 #define RTMEMPAGEALLOC_F_VALID_MASK UINT32_C(0x0000000f)
514 /** @} */
517 * Free a memory block allocated with RTMemPageAlloc() or RTMemPageAllocZ().
519 * @param pv Pointer to the block as it was returned by the allocation function.
520 * NULL will be ignored.
521 * @param cb The allocation size. Will be rounded up to page size.
522 * Ignored if @a pv is NULL.
524 RTDECL(void) RTMemPageFree(void *pv, size_t cb) RT_NO_THROW_PROTO;
526 /** Page level protection flags for RTMemProtect().
527 * @{
529 /** No access at all. */
530 #define RTMEM_PROT_NONE 0
531 /** Read access. */
532 #define RTMEM_PROT_READ 1
533 /** Write access. */
534 #define RTMEM_PROT_WRITE 2
535 /** Execute access. */
536 #define RTMEM_PROT_EXEC 4
537 /** @} */
540 * Change the page level protection of a memory region.
542 * @returns iprt status code.
543 * @param pv Start of the region. Will be rounded down to nearest page boundary.
544 * @param cb Size of the region. Will be rounded up to the nearest page boundary.
545 * @param fProtect The new protection, a combination of the RTMEM_PROT_* defines.
547 RTDECL(int) RTMemProtect(void *pv, size_t cb, unsigned fProtect) RT_NO_THROW_PROTO;
550 * Goes thru some pains to make sure the specified memory block is thoroughly
551 * scrambled.
553 * @param pv The start of the memory block.
554 * @param cb The size of the memory block.
555 * @param cMinPasses The minimum number of passes to make.
557 RTDECL(void) RTMemWipeThoroughly(void *pv, size_t cb, size_t cMinPasses) RT_NO_THROW_PROTO;
560 /** @def RTMEM_WILL_LEAK
561 * Macro for hinting that a memory allocation @a a_pv will leak.
563 * @note This shall only be used in code that doesn't allocate the object.
564 * Code allocating memory knowing it will leak shall start the allocation
565 * tag string with 'will-leak:'.
567 /** @def RTMEM_MAY_LEAK
568 * Macro for hinting that a memory allocation @a a_pv may leak.
570 * @note This shall only be used in code that doesn't allocate the object.
571 * Code allocating memory knowing it may leak shall start the allocation
572 * tag string with 'may-leak:'.
574 #ifdef IPRT_WITH_GCC_SANITIZER
575 # define RTMEM_WILL_LEAK(a_pv) __lsan_ignore_object(a_pv)
576 # define RTMEM_MAY_LEAK(a_pv) __lsan_ignore_object(a_pv)
577 #else
578 # define RTMEM_WILL_LEAK(a_pv) do { } while (0)
579 # define RTMEM_MAY_LEAK(a_pv) do { } while (0)
580 #endif
583 /** @def RTMEM_IMPLEMENT_NEW_AND_DELETE
584 * Provides a new and delete implementation to a class using IPRT's RTMem
585 * allocator.
587 #if !defined(RTMEM_WRAP_SOME_NEW_AND_DELETE_TO_EF) || defined(RTMEM_NO_WRAP_SOME_NEW_AND_DELETE_TO_EF)
588 # ifdef RT_EXCEPTIONS_ENABLED
589 # define RTMEM_IMPLEMENT_NEW_AND_DELETE() \
590 void *operator new(size_t cb) RT_THROW(std::bad_alloc) \
592 void *pv = RTMemAlloc(cb); \
593 if (RT_LIKELY(pv)) \
594 return pv; \
595 throw std::bad_alloc(); \
597 void *operator new(size_t cb, const std::nothrow_t &nothrow_constant) RT_NO_THROW_DEF \
599 NOREF(nothrow_constant); \
600 return RTMemAlloc(cb); \
602 void *operator new(size_t cb, void *pvBuf) RT_NO_THROW_DEF \
604 NOREF(cb); \
605 return pvBuf; \
607 void *operator new[](size_t cb) RT_THROW(std::bad_alloc) \
609 void *pv = RTMemAlloc(cb); \
610 if (RT_LIKELY(pv)) \
611 return pv; \
612 throw std::bad_alloc(); \
614 void *operator new[](size_t cb, const std::nothrow_t &nothrow_constant) RT_NO_THROW_DEF \
616 NOREF(nothrow_constant); \
617 return RTMemAlloc(cb); \
620 void operator delete(void *pv) RT_NO_THROW_DEF \
622 RTMemFree(pv); \
624 void operator delete(void *pv, const std::nothrow_t &nothrow_constant) RT_NO_THROW_DEF \
626 NOREF(nothrow_constant); \
627 RTMemFree(pv); \
629 void operator delete[](void *pv) RT_NO_THROW_DEF \
631 RTMemFree(pv); \
633 void operator delete[](void *pv, const std::nothrow_t &nothrow_constant) RT_NO_THROW_DEF \
635 NOREF(nothrow_constant); \
636 RTMemFree(pv); \
639 typedef int UsingIprtNewAndDeleteOperators
640 # else /* !RT_EXCEPTIONS_ENABLED */
641 # define RTMEM_IMPLEMENT_NEW_AND_DELETE() \
642 void *operator new(size_t cb) \
644 return RTMemAlloc(cb); \
646 void *operator new(size_t cb, const std::nothrow_t &nothrow_constant) \
648 NOREF(nothrow_constant); \
649 return RTMemAlloc(cb); \
651 void *operator new(size_t cb, void *pvBuf) RT_NO_THROW_DEF \
653 NOREF(cb); \
654 return pvBuf; \
656 void *operator new[](size_t cb) \
658 return RTMemAlloc(cb); \
660 void *operator new[](size_t cb, const std::nothrow_t &nothrow_constant) \
662 NOREF(nothrow_constant); \
663 return RTMemAlloc(cb); \
666 void operator delete(void *pv) \
668 RTMemFree(pv); \
670 void operator delete(void *pv, const std::nothrow_t &nothrow_constant) \
672 NOREF(nothrow_constant); \
673 RTMemFree(pv); \
675 void operator delete[](void *pv) \
677 RTMemFree(pv); \
679 void operator delete[](void *pv, const std::nothrow_t &nothrow_constant) \
681 NOREF(nothrow_constant); \
682 RTMemFree(pv); \
685 typedef int UsingIprtNewAndDeleteOperators
686 # endif /* !RT_EXCEPTIONS_ENABLED */
687 #else /* defined(RTMEM_WRAP_SOME_NEW_AND_DELETE_TO_EF) && !defined(RTMEM_NO_WRAP_SOME_NEW_AND_DELETE_TO_EF) */
688 # define RTMEM_IMPLEMENT_NEW_AND_DELETE() RTMEMEF_NEW_AND_DELETE_OPERATORS()
689 #endif /* defined(RTMEM_WRAP_SOME_NEW_AND_DELETE_TO_EF) && !defined(RTMEM_NO_WRAP_SOME_NEW_AND_DELETE_TO_EF) */
692 #ifdef IN_RING0
695 * Allocates physical contiguous memory (below 4GB).
696 * The allocation is page aligned and the content is undefined.
698 * @returns Pointer to the memory block. This is page aligned.
699 * @param pPhys Where to store the physical address.
700 * @param cb The allocation size in bytes. This is always
701 * rounded up to PAGE_SIZE.
703 RTR0DECL(void *) RTMemContAlloc(PRTCCPHYS pPhys, size_t cb) RT_NO_THROW_PROTO;
706 * Frees memory allocated ysing RTMemContAlloc().
708 * @param pv Pointer to return from RTMemContAlloc().
709 * @param cb The cb parameter passed to RTMemContAlloc().
711 RTR0DECL(void) RTMemContFree(void *pv, size_t cb) RT_NO_THROW_PROTO;
714 * Copy memory from an user mode buffer into a kernel buffer.
716 * @retval VINF_SUCCESS on success.
717 * @retval VERR_ACCESS_DENIED on error.
719 * @param pvDst The kernel mode destination address.
720 * @param R3PtrSrc The user mode source address.
721 * @param cb The number of bytes to copy.
723 RTR0DECL(int) RTR0MemUserCopyFrom(void *pvDst, RTR3PTR R3PtrSrc, size_t cb);
726 * Copy memory from a kernel buffer into a user mode one.
728 * @retval VINF_SUCCESS on success.
729 * @retval VERR_ACCESS_DENIED on error.
731 * @param R3PtrDst The user mode destination address.
732 * @param pvSrc The kernel mode source address.
733 * @param cb The number of bytes to copy.
735 RTR0DECL(int) RTR0MemUserCopyTo(RTR3PTR R3PtrDst, void const *pvSrc, size_t cb);
738 * Tests if the specified address is in the user addressable range.
740 * This function does not check whether the memory at that address is accessible
741 * or anything of that sort, only if the address it self is in the user mode
742 * range.
744 * @returns true if it's in the user addressable range. false if not.
745 * @param R3Ptr The user mode pointer to test.
747 * @remarks Some systems may have overlapping kernel and user address ranges.
748 * One prominent example of this is the x86 version of Mac OS X. Use
749 * RTR0MemAreKrnlAndUsrDifferent() to check.
751 RTR0DECL(bool) RTR0MemUserIsValidAddr(RTR3PTR R3Ptr);
754 * Tests if the specified address is in the kernel mode range.
756 * This function does not check whether the memory at that address is accessible
757 * or anything of that sort, only if the address it self is in the kernel mode
758 * range.
760 * @returns true if it's in the kernel range. false if not.
761 * @param pv The alleged kernel mode pointer.
763 * @remarks Some systems may have overlapping kernel and user address ranges.
764 * One prominent example of this is the x86 version of Mac OS X. Use
765 * RTR0MemAreKrnlAndUsrDifferent() to check.
767 RTR0DECL(bool) RTR0MemKernelIsValidAddr(void *pv);
770 * Are user mode and kernel mode address ranges distinctly different.
772 * This determines whether RTR0MemKernelIsValidAddr and RTR0MemUserIsValidAddr
773 * can be used for deciding whether some arbitrary address is a user mode or a
774 * kernel mode one.
776 * @returns true if they are, false if not.
778 RTR0DECL(bool) RTR0MemAreKrnlAndUsrDifferent(void);
781 * Copy memory from an potentially unsafe kernel mode location and into a safe
782 * (kernel) buffer.
784 * @retval VINF_SUCCESS on success.
785 * @retval VERR_ACCESS_DENIED on error.
786 * @retval VERR_NOT_SUPPORTED if not (yet) supported.
788 * @param pvDst The destination address (safe).
789 * @param pvSrc The source address (potentially unsafe).
790 * @param cb The number of bytes to copy.
792 RTR0DECL(int) RTR0MemKernelCopyFrom(void *pvDst, void const *pvSrc, size_t cb);
795 * Copy from a safe (kernel) buffer and to a potentially unsafe kenrel mode
796 * location.
798 * @retval VINF_SUCCESS on success.
799 * @retval VERR_ACCESS_DENIED on error.
800 * @retval VERR_NOT_SUPPORTED if not (yet) supported.
802 * @param pvDst The destination address (potentially unsafe).
803 * @param pvSrc The source address (safe).
804 * @param cb The number of bytes to copy.
806 RTR0DECL(int) RTR0MemKernelCopyTo(void *pvDst, void const *pvSrc, size_t cb);
808 #endif /* IN_RING0 */
811 /** @name Electrical Fence Version of some APIs.
812 * @{
816 * Same as RTMemTmpAllocTag() except that it's fenced.
818 * @returns Pointer to the allocated memory.
819 * @returns NULL on failure.
820 * @param cb Size in bytes of the memory block to allocate.
821 * @param pszTag Allocation tag used for statistics and such.
822 * @param SRC_POS The source position where call is being made from.
823 * Use RT_SRC_POS when possible. Optional.
825 RTDECL(void *) RTMemEfTmpAlloc(size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
828 * Same as RTMemTmpAllocZTag() except that it's fenced.
830 * @returns Pointer to the allocated memory.
831 * @returns NULL on failure.
832 * @param cb Size in bytes of the memory block to allocate.
833 * @param pszTag Allocation tag used for statistics and such.
834 * @param SRC_POS The source position where call is being made from. Use
835 * RT_SRC_POS when possible. Optional.
837 RTDECL(void *) RTMemEfTmpAllocZ(size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
840 * Same as RTMemTmpFree() except that it's for fenced memory.
842 * @param pv Pointer to memory block.
843 * @param SRC_POS The source position where call is being made from. Use
844 * RT_SRC_POS when possible. Optional.
846 RTDECL(void) RTMemEfTmpFree(void *pv, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
849 * Same as RTMemTmpFreeZ() except that it's for fenced memory.
851 * @param pv Pointer to memory block.
852 * @param cb Size of the memory block.
853 * @param SRC_POS The source position where call is being made from. Use
854 * RT_SRC_POS when possible. Optional.
856 RTDECL(void) RTMemEfTmpFreeZ(void *pv, size_t cb, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
859 * Same as RTMemAllocTag() except that it's fenced.
861 * @returns Pointer to the allocated memory. Free with RTMemEfFree().
862 * @returns NULL on failure.
863 * @param cb Size in bytes of the memory block to allocate.
864 * @param pszTag Allocation tag used for statistics and such.
865 * @param SRC_POS The source position where call is being made from. Use
866 * RT_SRC_POS when possible. Optional.
868 RTDECL(void *) RTMemEfAlloc(size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
871 * Same as RTMemAllocZTag() except that it's fenced.
873 * @returns Pointer to the allocated memory.
874 * @returns NULL on failure.
875 * @param cb Size in bytes of the memory block to allocate.
876 * @param pszTag Allocation tag used for statistics and such.
877 * @param SRC_POS The source position where call is being made from. Use
878 * RT_SRC_POS when possible. Optional.
880 RTDECL(void *) RTMemEfAllocZ(size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
883 * Same as RTMemAllocVarTag() except that it's fenced.
885 * @returns Pointer to the allocated memory. Free with RTMemEfFree().
886 * @returns NULL on failure.
887 * @param cbUnaligned 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.
892 RTDECL(void *) RTMemEfAllocVar(size_t cbUnaligned, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
895 * Same as RTMemAllocZVarTag() except that it's fenced.
897 * @returns Pointer to the allocated memory.
898 * @returns NULL on failure.
899 * @param cbUnaligned 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.
904 RTDECL(void *) RTMemEfAllocZVar(size_t cbUnaligned, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
907 * Same as RTMemReallocTag() except that it's fenced.
909 * @returns Pointer to the allocated memory.
910 * @returns NULL on failure.
911 * @param pvOld The memory block to reallocate.
912 * @param cbNew The new block size (in bytes).
913 * @param pszTag Allocation tag used for statistics and such.
914 * @param SRC_POS The source position where call is being made from. Use
915 * RT_SRC_POS when possible. Optional.
917 RTDECL(void *) RTMemEfRealloc(void *pvOld, size_t cbNew, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
920 * Same as RTMemReallocZTag() except that it's fenced.
922 * @returns Pointer to the allocated memory.
923 * @returns NULL on failure.
924 * @param pvOld The memory block to reallocate.
925 * @param cbOld The old block size (in bytes).
926 * @param cbNew The new block size (in bytes).
927 * @param pszTag Allocation tag used for statistics and such.
928 * @param SRC_POS The source position where call is being made from. Use
929 * RT_SRC_POS when possible. Optional.
931 RTDECL(void *) RTMemEfReallocZ(void *pvOld, size_t cbOld, size_t cbNew, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
934 * Free memory allocated by any of the RTMemEf* allocators.
936 * @param pv Pointer to memory block.
937 * @param SRC_POS The source position where call is being made from. Use
938 * RT_SRC_POS when possible. Optional.
940 RTDECL(void) RTMemEfFree(void *pv, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
943 * Clear and free memory allocated by any of the RTMemEf* allocators.
945 * @param pv Pointer to memory block.
946 * @param cb Size of the allocation.
947 * @param SRC_POS The source position where call is being made from. Use
948 * RT_SRC_POS when possible. Optional.
950 RTDECL(void) RTMemEfFreeZ(void *pv, size_t cb, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
953 * Same as RTMemDupTag() except that it's fenced.
955 * @returns New heap block with the duplicate data.
956 * @returns NULL if we're out of memory.
957 * @param pvSrc The memory to duplicate.
958 * @param cb The amount of memory to duplicate.
959 * @param pszTag Allocation tag used for statistics and such.
960 * @param SRC_POS The source position where call is being made from. Use
961 * RT_SRC_POS when possible. Optional.
963 RTDECL(void *) RTMemEfDup(const void *pvSrc, size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
966 * Same as RTMemEfDupExTag except that it's fenced.
968 * @returns New heap block with the duplicate data.
969 * @returns NULL if we're out of memory.
970 * @param pvSrc The memory to duplicate.
971 * @param cbSrc The amount of memory to duplicate.
972 * @param cbExtra The amount of extra memory to allocate and zero.
973 * @param pszTag Allocation tag used for statistics and such.
974 * @param SRC_POS The source position where call is being made from. Use
975 * RT_SRC_POS when possible. Optional.
977 RTDECL(void *) RTMemEfDupEx(const void *pvSrc, size_t cbSrc, size_t cbExtra, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW_PROTO;
979 /** @def RTMEM_WRAP_SOME_NEW_AND_DELETE_TO_EF
980 * Define RTMEM_WRAP_SOME_NEW_AND_DELETE_TO_EF to enable electric fence new and
981 * delete operators for classes which uses the RTMEMEF_NEW_AND_DELETE_OPERATORS
982 * macro.
984 /** @def RTMEMEF_NEW_AND_DELETE_OPERATORS
985 * Defines the electric fence new and delete operators for a class when
986 * RTMEM_WRAP_SOME_NEW_AND_DELETE_TO_EF is define.
988 /** @def RTR0MEMEF_NEW_AND_DELETE_OPERATORS_IOKIT
989 * Defines the electric fence new and delete operators for an IOKit class when
990 * RTMEM_WRAP_SOME_NEW_AND_DELETE_TO_EF is define.
992 * This differs from RTMEMEF_NEW_AND_DELETE_OPERATORS in that the memory we
993 * allocate is initialized to zero. It is also assuming we don't have nothrow
994 * variants and exceptions, so fewer variations.
996 #if defined(RTMEM_WRAP_SOME_NEW_AND_DELETE_TO_EF) && !defined(RTMEM_NO_WRAP_SOME_NEW_AND_DELETE_TO_EF)
997 # if defined(RT_EXCEPTIONS_ENABLED)
998 # define RTMEMEF_NEW_AND_DELETE_OPERATORS() \
999 void *operator new(size_t cb) RT_THROW(std::bad_alloc) \
1001 void *pv = RTMemEfAlloc(cb, RTMEM_TAG, RT_SRC_POS); \
1002 if (RT_LIKELY(pv)) \
1003 return pv; \
1004 throw std::bad_alloc(); \
1006 void *operator new(size_t cb, const std::nothrow_t &nothrow_constant) RT_NO_THROW_DEF \
1008 NOREF(nothrow_constant); \
1009 return RTMemEfAlloc(cb, RTMEM_TAG, RT_SRC_POS); \
1011 void *operator new(size_t cb, void *pvBuf) RT_NO_THROW_DEF \
1013 NOREF(cb); \
1014 return pvBuf; \
1016 void *operator new[](size_t cb) RT_THROW(std::bad_alloc) \
1018 void *pv = RTMemEfAlloc(cb, RTMEM_TAG, RT_SRC_POS); \
1019 if (RT_LIKELY(pv)) \
1020 return pv; \
1021 throw std::bad_alloc(); \
1023 void *operator new[](size_t cb, const std::nothrow_t &nothrow_constant) RT_NO_THROW_DEF \
1025 NOREF(nothrow_constant); \
1026 return RTMemEfAlloc(cb, RTMEM_TAG, RT_SRC_POS); \
1029 void operator delete(void *pv) RT_NO_THROW_DEF \
1031 RTMemEfFree(pv, RT_SRC_POS); \
1033 void operator delete(void *pv, const std::nothrow_t &nothrow_constant) RT_NO_THROW_DEF \
1035 NOREF(nothrow_constant); \
1036 RTMemEfFree(pv, RT_SRC_POS); \
1038 void operator delete[](void *pv) RT_NO_THROW_DEF \
1040 RTMemEfFree(pv, RT_SRC_POS); \
1042 void operator delete[](void *pv, const std::nothrow_t &nothrow_constant) RT_NO_THROW_DEF \
1044 NOREF(nothrow_constant); \
1045 RTMemEfFree(pv, RT_SRC_POS); \
1048 typedef int UsingElectricNewAndDeleteOperators
1049 # else
1050 # define RTMEMEF_NEW_AND_DELETE_OPERATORS() \
1051 void *operator new(size_t cb) \
1053 return RTMemEfAlloc(cb, RTMEM_TAG, RT_SRC_POS); \
1055 void *operator new(size_t cb, const std::nothrow_t &nothrow_constant) \
1057 NOREF(nothrow_constant); \
1058 return RTMemEfAlloc(cb, RTMEM_TAG, RT_SRC_POS); \
1060 void *operator new(size_t cb, void *pvBuf) RT_NO_THROW_DEF \
1062 NOREF(cb); \
1063 return pvBuf; \
1065 void *operator new[](size_t cb) \
1067 return RTMemEfAlloc(cb, RTMEM_TAG, RT_SRC_POS); \
1069 void *operator new[](size_t cb, const std::nothrow_t &nothrow_constant) \
1071 NOREF(nothrow_constant); \
1072 return RTMemEfAlloc(cb, RTMEM_TAG, RT_SRC_POS); \
1075 void operator delete(void *pv) \
1077 RTMemEfFree(pv, RT_SRC_POS); \
1079 void operator delete(void *pv, const std::nothrow_t &nothrow_constant) \
1081 NOREF(nothrow_constant); \
1082 RTMemEfFree(pv, RT_SRC_POS); \
1084 void operator delete[](void *pv) \
1086 RTMemEfFree(pv, RT_SRC_POS); \
1088 void operator delete[](void *pv, const std::nothrow_t &nothrow_constant) \
1090 NOREF(nothrow_constant); \
1091 RTMemEfFree(pv, RT_SRC_POS); \
1094 typedef int UsingElectricNewAndDeleteOperators
1095 # endif
1096 # define RTR0MEMEF_NEW_AND_DELETE_OPERATORS_IOKIT() \
1097 void *operator new(size_t cb) \
1099 return RTMemEfAllocZ(cb, RTMEM_TAG, RT_SRC_POS); \
1101 void *operator new[](size_t cb) \
1103 return RTMemEfAllocZ(cb, RTMEM_TAG, RT_SRC_POS); \
1106 void operator delete(void *pv) \
1108 RTMemEfFree(pv, RT_SRC_POS); \
1110 void operator delete[](void *pv) \
1112 RTMemEfFree(pv, RT_SRC_POS); \
1115 typedef int UsingElectricNewAndDeleteOperators
1116 #else
1117 # define RTMEMEF_NEW_AND_DELETE_OPERATORS() \
1118 typedef int UsingDefaultNewAndDeleteOperators
1119 # define RTR0MEMEF_NEW_AND_DELETE_OPERATORS_IOKIT() \
1120 typedef int UsingDefaultNewAndDeleteOperators
1121 #endif
1122 #ifdef DOXYGEN_RUNNING
1123 # define RTMEM_WRAP_SOME_NEW_AND_DELETE_TO_EF
1124 #endif
1126 /** @def RTMEM_WRAP_TO_EF_APIS
1127 * Define RTMEM_WRAP_TO_EF_APIS to wrap RTMem APIs to RTMemEf APIs.
1129 #if defined(RTMEM_WRAP_TO_EF_APIS) && !defined(RTMEM_NO_WRAP_TO_EF_APIS) \
1130 && ( defined(IN_RING3) || ( defined(IN_RING0) && !defined(IN_RING0_AGNOSTIC) && (defined(RT_OS_DARWIN) || 0) ) )
1131 # define RTMemTmpAllocTag(cb, pszTag) RTMemEfTmpAlloc((cb), (pszTag), RT_SRC_POS)
1132 # define RTMemTmpAllocZTag(cb, pszTag) RTMemEfTmpAllocZ((cb), (pszTag), RT_SRC_POS)
1133 # define RTMemTmpFree(pv) RTMemEfTmpFree((pv), RT_SRC_POS)
1134 # define RTMemTmpFreeZ(pv, cb) RTMemEfTmpFreeZ((pv), (cb), RT_SRC_POS)
1135 # define RTMemAllocTag(cb, pszTag) RTMemEfAlloc((cb), (pszTag), RT_SRC_POS)
1136 # define RTMemAllocZTag(cb, pszTag) RTMemEfAllocZ((cb), (pszTag), RT_SRC_POS)
1137 # define RTMemAllocVarTag(cbUnaligned, pszTag) RTMemEfAllocVar((cbUnaligned), (pszTag), RT_SRC_POS)
1138 # define RTMemAllocZVarTag(cbUnaligned, pszTag) RTMemEfAllocZVar((cbUnaligned), (pszTag), RT_SRC_POS)
1139 # define RTMemReallocTag(pvOld, cbNew, pszTag) RTMemEfRealloc((pvOld), (cbNew), (pszTag), RT_SRC_POS)
1140 # define RTMemReallocZTag(pvOld, cbOld, cbNew, pszTag) RTMemEfReallocZ((pvOld), (cbOld), (cbNew), (pszTag), RT_SRC_POS)
1141 # define RTMemFree(pv) RTMemEfFree((pv), RT_SRC_POS)
1142 # define RTMemFreeZ(pv, cb) RTMemEfFreeZ((pv), (cb), RT_SRC_POS)
1143 # define RTMemDupTag(pvSrc, cb, pszTag) RTMemEfDup((pvSrc), (cb), (pszTag), RT_SRC_POS)
1144 # define RTMemDupExTag(pvSrc, cbSrc, cbExtra, pszTag) RTMemEfDupEx((pvSrc), (cbSrc), (cbExtra), (pszTag), RT_SRC_POS)
1145 #endif
1146 #ifdef DOXYGEN_RUNNING
1147 # define RTMEM_WRAP_TO_EF_APIS
1148 #endif
1151 * Fenced drop-in replacement for RTMemTmpAllocTag.
1152 * @copydoc RTMemTmpAllocTag
1154 RTDECL(void *) RTMemEfTmpAllocNP(size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
1157 * Fenced drop-in replacement for RTMemTmpAllocZTag.
1158 * @copydoc RTMemTmpAllocZTag
1160 RTDECL(void *) RTMemEfTmpAllocZNP(size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
1163 * Fenced drop-in replacement for RTMemTmpFree.
1164 * @copydoc RTMemTmpFree
1166 RTDECL(void) RTMemEfTmpFreeNP(void *pv) RT_NO_THROW_PROTO;
1169 * Fenced drop-in replacement for RTMemTmpFreeZ.
1170 * @copydoc RTMemTmpFreeZ
1172 RTDECL(void) RTMemEfTmpFreeZNP(void *pv, size_t cb) RT_NO_THROW_PROTO;
1175 * Fenced drop-in replacement for RTMemAllocTag.
1176 * @copydoc RTMemAllocTag
1178 RTDECL(void *) RTMemEfAllocNP(size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
1181 * Fenced drop-in replacement for RTMemAllocZTag.
1182 * @copydoc RTMemAllocZTag
1184 RTDECL(void *) RTMemEfAllocZNP(size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
1187 * Fenced drop-in replacement for RTMemAllocVarTag
1188 * @copydoc RTMemAllocVarTag
1190 RTDECL(void *) RTMemEfAllocVarNP(size_t cbUnaligned, const char *pszTag) RT_NO_THROW_PROTO;
1193 * Fenced drop-in replacement for RTMemAllocZVarTag.
1194 * @copydoc RTMemAllocZVarTag
1196 RTDECL(void *) RTMemEfAllocZVarNP(size_t cbUnaligned, const char *pszTag) RT_NO_THROW_PROTO;
1199 * Fenced drop-in replacement for RTMemReallocTag.
1200 * @copydoc RTMemReallocTag
1202 RTDECL(void *) RTMemEfReallocNP(void *pvOld, size_t cbNew, const char *pszTag) RT_NO_THROW_PROTO;
1205 * Fenced drop-in replacement for RTMemReallocZTag.
1206 * @copydoc RTMemReallocZTag
1208 RTDECL(void *) RTMemEfReallocZNP(void *pvOld, size_t cbOld, size_t cbNew, const char *pszTag) RT_NO_THROW_PROTO;
1211 * Fenced drop-in replacement for RTMemFree.
1212 * @copydoc RTMemFree
1214 RTDECL(void) RTMemEfFreeNP(void *pv) RT_NO_THROW_PROTO;
1217 * Fenced drop-in replacement for RTMemFreeZ.
1218 * @copydoc RTMemFreeZ
1220 RTDECL(void) RTMemEfFreeZNP(void *pv, size_t cb) RT_NO_THROW_PROTO;
1223 * Fenced drop-in replacement for RTMemDupExTag.
1224 * @copydoc RTMemDupTag
1226 RTDECL(void *) RTMemEfDupNP(const void *pvSrc, size_t cb, const char *pszTag) RT_NO_THROW_PROTO;
1229 * Fenced drop-in replacement for RTMemDupExTag.
1230 * @copydoc RTMemDupExTag
1232 RTDECL(void *) RTMemEfDupExNP(const void *pvSrc, size_t cbSrc, size_t cbExtra, const char *pszTag) RT_NO_THROW_PROTO;
1234 /** @} */
1236 RT_C_DECLS_END
1238 /** @} */
1241 #endif /* !IPRT_INCLUDED_mem_h */