VirtualBox

Changeset 31157 in vbox


Ignore:
Timestamp:
Jul 28, 2010 3:15:35 AM (14 years ago)
Author:
vboxsync
Message:

iprt,++: Tag allocation in all builds with a string, defaulting to FILE.

Location:
trunk
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/mem.h

    r30827 r31157  
    5656#define RTMEM_ALIGNMENT    8
    5757
    58 /**
    59  * Allocates temporary memory.
     58/** @def RTMEM_TAG
     59 * The default allocation tag used by the RTMem allocation APIs.
     60 *
     61 * When not defined before the inclusion of iprt/mem.h or iprt/memobj.h, this
     62 * will default to the pointer to the current file name.  The memory API will
     63 * make of use of this as pointer to a volatile but read-only string.
     64 */
     65#ifndef RTMEM_TAG
     66# define RTMEM_TAG   (__FILE__)
     67#endif
     68
     69
     70/** @name Allocate temporary memory.
     71 * @{ */
     72/**
     73 * Allocates temporary memory with default tag.
    6074 *
    6175 * Temporary memory blocks are used for not too large memory blocks which
     
    6579 *
    6680 * @returns Pointer to the allocated memory.
    67  * @returns NULL on failure.
     81 * @returns NULL on failure, assertion raised in strict builds.
    6882 * @param   cb      Size in bytes of the memory block to allocated.
    6983 */
    70 RTDECL(void *)  RTMemTmpAlloc(size_t cb) RT_NO_THROW;
    71 
    72 /**
    73  * Allocates zero'ed temporary memory.
     84#define RTMemTmpAlloc(cb)               RTMemTmpAllocTag((cb), RTMEM_TAG)
     85
     86/**
     87 * Allocates temporary memory with custom tag.
     88 *
     89 * Temporary memory blocks are used for not too large memory blocks which
     90 * are believed not to stick around for too long. Using this API instead
     91 * of RTMemAlloc() not only gives the heap manager room for optimization
     92 * but makes the code easier to read.
     93 *
     94 * @returns Pointer to the allocated memory.
     95 * @returns NULL on failure, assertion raised in strict builds.
     96 * @param   cb      Size in bytes of the memory block to allocated.
     97 * @param   pszTag  Allocation tag used for statistics and such.
     98 */
     99RTDECL(void *)  RTMemTmpAllocTag(size_t cb, const char *pszTag) RT_NO_THROW;
     100
     101/**
     102 * Allocates zero'ed temporary memory with default tag.
    74103 *
    75104 * Same as RTMemTmpAlloc() but the memory will be zero'ed.
    76105 *
    77106 * @returns Pointer to the allocated memory.
    78  * @returns NULL on failure.
     107 * @returns NULL on failure, assertion raised in strict builds.
    79108 * @param   cb      Size in bytes of the memory block to allocated.
    80109 */
    81 RTDECL(void *)  RTMemTmpAllocZ(size_t cb) RT_NO_THROW;
     110#define RTMemTmpAllocZ(cb)              RTMemTmpAllocZTag((cb), RTMEM_TAG)
     111
     112/**
     113 * Allocates zero'ed temporary memory with custom tag.
     114 *
     115 * Same as RTMemTmpAlloc() but the memory will be zero'ed.
     116 *
     117 * @returns Pointer to the allocated memory.
     118 * @returns NULL on failure, assertion raised in strict builds.
     119 * @param   cb      Size in bytes of the memory block to allocated.
     120 * @param   pszTag  Allocation tag used for statistics and such.
     121 */
     122RTDECL(void *)  RTMemTmpAllocZTag(size_t cb, const char *pszTag) RT_NO_THROW;
    82123
    83124/**
     
    88129RTDECL(void)    RTMemTmpFree(void *pv) RT_NO_THROW;
    89130
    90 
    91 /**
    92  * Allocates memory.
    93  *
    94  * @returns Pointer to the allocated memory.
    95  * @returns NULL on failure.
     131/** @}  */
     132
     133
     134/**
     135 * Allocates memory with default tag.
     136 *
     137 * @returns Pointer to the allocated memory.
     138 * @returns NULL on failure, assertion raised in strict builds.
    96139 * @param   cb      Size in bytes of the memory block to allocated.
    97  */
    98 RTDECL(void *)  RTMemAlloc(size_t cb) RT_NO_THROW;
    99 
    100 /**
    101  * Allocates zero'ed memory.
     140 * @param   pszTag  Allocation tag used for statistics and such.
     141 */
     142#define RTMemAlloc(cb)                  RTMemAllocTag((cb), RTMEM_TAG)
     143
     144/**
     145 * Allocates memory with custom tag.
     146 *
     147 * @returns Pointer to the allocated memory.
     148 * @returns NULL on failure, assertion raised in strict builds.
     149 * @param   cb      Size in bytes of the memory block to allocated.
     150 * @param   pszTag  Allocation tag used for statistics and such.
     151 */
     152RTDECL(void *)  RTMemAllocTag(size_t cb, const char *pszTag) RT_NO_THROW;
     153
     154/**
     155 * Allocates zero'ed memory with default tag.
    102156 *
    103157 * Instead of memset(pv, 0, sizeof()) use this when you want zero'ed
     
    109163 * @param   cb      Size in bytes of the memory block to allocated.
    110164 */
    111 RTDECL(void *)  RTMemAllocZ(size_t cb) RT_NO_THROW;
     165#define RTMemAllocZ(cb)                 RTMemAllocZTag((cb), RTMEM_TAG)
     166
     167/**
     168 * Allocates zero'ed memory with custom tag.
     169 *
     170 * Instead of memset(pv, 0, sizeof()) use this when you want zero'ed
     171 * memory. This keeps the code smaller and the heap can skip the memset
     172 * in about 0.42% of calls :-).
     173 *
     174 * @returns Pointer to the allocated memory.
     175 * @returns NULL on failure.
     176 * @param   cb      Size in bytes of the memory block to allocated.
     177 * @param   pszTag  Allocation tag used for statistics and such.
     178 */
     179RTDECL(void *)  RTMemAllocZTag(size_t cb, const char *pszTag) RT_NO_THROW;
    112180
    113181/**
     
    118186 * @param   cbUnaligned         The unaligned size.
    119187 */
    120 RTDECL(void *) RTMemAllocVar(size_t cbUnaligned);
     188#define RTMemAllocVar(cbUnaligned)      RTMemAllocVarTag((cbUnaligned), RTMEM_TAG)
     189
     190/**
     191 * Wrapper around RTMemAllocTag for automatically aligning variable sized
     192 * allocations so that the various electric fence heaps works correctly.
     193 *
     194 * @returns See RTMemAlloc.
     195 * @param   cbUnaligned         The unaligned size.
     196 * @param   pszTag              Allocation tag used for statistics and such.
     197 */
     198RTDECL(void *) RTMemAllocVarTag(size_t cbUnaligned, const char *pszTag) RT_NO_THROW;
    121199
    122200/**
     
    127205 * @param   cbUnaligned         The unaligned size.
    128206 */
    129 RTDECL(void *) RTMemAllocZVar(size_t cbUnaligned);
    130 
    131 /**
    132  * Duplicates a chunk of memory into a new heap block.
     207#define RTMemAllocZVar(cbUnaligned)     RTMemAllocZVarTag((cbUnaligned), RTMEM_TAG)
     208
     209/**
     210 * Wrapper around RTMemAllocZTag for automatically aligning variable sized
     211 * allocations so that the various electric fence heaps works correctly.
     212 *
     213 * @returns See RTMemAllocZ.
     214 * @param   cbUnaligned         The unaligned size.
     215 * @param   pszTag              Allocation tag used for statistics and such.
     216 */
     217RTDECL(void *) RTMemAllocZVarTag(size_t cbUnaligned, const char *pszTag) RT_NO_THROW;
     218
     219/**
     220 * Duplicates a chunk of memory into a new heap block (default tag).
    133221 *
    134222 * @returns New heap block with the duplicate data.
     
    137225 * @param   cb      The amount of memory to duplicate.
    138226 */
    139 RTDECL(void *) RTMemDup(const void *pvSrc, size_t cb) RT_NO_THROW;
    140 
    141 /**
    142  * Duplicates a chunk of memory into a new heap block with some
    143  * additional zeroed memory.
     227#define RTMemDup(pvSrc, cb)             RTMemDupTag((pvSrc), (cb), RTMEM_TAG)
     228
     229/**
     230 * Duplicates a chunk of memory into a new heap block (custom tag).
     231 *
     232 * @returns New heap block with the duplicate data.
     233 * @returns NULL if we're out of memory.
     234 * @param   pvSrc   The memory to duplicate.
     235 * @param   cb      The amount of memory to duplicate.
     236 * @param   pszTag  Allocation tag used for statistics and such.
     237 */
     238RTDECL(void *) RTMemDupTag(const void *pvSrc, size_t cb, const char *pszTag) RT_NO_THROW;
     239
     240/**
     241 * Duplicates a chunk of memory into a new heap block with some additional
     242 * zeroed memory (default tag).
    144243 *
    145244 * @returns New heap block with the duplicate data.
     
    149248 * @param   cbExtra The amount of extra memory to allocate and zero.
    150249 */
    151 RTDECL(void *) RTMemDupEx(const void *pvSrc, size_t cbSrc, size_t cbExtra) RT_NO_THROW;
    152 
    153 /**
    154  * Reallocates memory.
     250#define RTMemDupEx(pvSrc, cbSrc, cbExtra)   RTMemDupExTag((pvSrc), (cbSrc), (cbExtra), RTMEM_TAG)
     251
     252/**
     253 * Duplicates a chunk of memory into a new heap block with some additional
     254 * zeroed memory (default tag).
     255 *
     256 * @returns New heap block with the duplicate data.
     257 * @returns NULL if we're out of memory.
     258 * @param   pvSrc   The memory to duplicate.
     259 * @param   cbSrc   The amount of memory to duplicate.
     260 * @param   cbExtra The amount of extra memory to allocate and zero.
     261 * @param   pszTag  Allocation tag used for statistics and such.
     262 */
     263RTDECL(void *) RTMemDupExTag(const void *pvSrc, size_t cbSrc, size_t cbExtra, const char *pszTag) RT_NO_THROW;
     264
     265/**
     266 * Reallocates memory with default tag.
    155267 *
    156268 * @returns Pointer to the allocated memory.
     
    159271 * @param   cbNew   The new block size (in bytes).
    160272 */
    161 RTDECL(void *)  RTMemRealloc(void *pvOld, size_t cbNew) RT_NO_THROW;
     273#define RTMemRealloc(pvOld, cbNew)          RTMemReallocTag((pvOld), (cbNew), RTMEM_TAG)
     274
     275/**
     276 * Reallocates memory with custom tag.
     277 *
     278 * @returns Pointer to the allocated memory.
     279 * @returns NULL on failure.
     280 * @param   pvOld   The memory block to reallocate.
     281 * @param   cbNew   The new block size (in bytes).
     282 * @param   pszTag  Allocation tag used for statistics and such.
     283 */
     284RTDECL(void *)  RTMemReallocTag(void *pvOld, size_t cbNew, const char *pszTag) RT_NO_THROW;
    162285
    163286/**
     
    168291RTDECL(void)    RTMemFree(void *pv) RT_NO_THROW;
    169292
    170 /**
    171  * Allocates memory which may contain code.
     293
     294
     295/**
     296 * Allocates memory which may contain code (default tag).
    172297 *
    173298 * @returns Pointer to the allocated memory.
     
    175300 * @param   cb      Size in bytes of the memory block to allocate.
    176301 */
    177 RTDECL(void *)  RTMemExecAlloc(size_t cb) RT_NO_THROW;
     302#define RTMemExecAlloc(cb)              RTMemExecAllocTag((cb), RTMEM_TAG)
     303
     304/**
     305 * Allocates memory which may contain code (custom tag).
     306 *
     307 * @returns Pointer to the allocated memory.
     308 * @returns NULL on failure.
     309 * @param   cb      Size in bytes of the memory block to allocate.
     310 * @param   pszTag  Allocation tag used for statistics and such.
     311 */
     312RTDECL(void *)  RTMemExecAllocTag(size_t cb, const char *pszTag) RT_NO_THROW;
    178313
    179314/**
     
    204339
    205340/**
    206  * Allocate page aligned memory.
     341 * Allocate page aligned memory with default tag.
    207342 *
    208343 * @returns Pointer to the allocated memory.
     
    210345 * @param   cb  Size of the memory block. Will be rounded up to page size.
    211346 */
    212 RTDECL(void *) RTMemPageAlloc(size_t cb) RT_NO_THROW;
    213 
    214 /**
    215  * Allocate zero'ed page aligned memory.
     347#define RTMemPageAlloc(cb)              RTMemPageAllocTag((cb), RTMEM_TAG)
     348
     349/**
     350 * Allocate page aligned memory with custom tag.
    216351 *
    217352 * @returns Pointer to the allocated memory.
    218353 * @returns NULL if we're out of memory.
    219354 * @param   cb  Size of the memory block. Will be rounded up to page size.
    220  */
    221 RTDECL(void *) RTMemPageAllocZ(size_t cb) RT_NO_THROW;
     355 * @param   pszTag  Allocation tag used for statistics and such.
     356 */
     357RTDECL(void *) RTMemPageAllocTag(size_t cb, const char *pszTag) RT_NO_THROW;
     358
     359/**
     360 * Allocate zero'ed page aligned memory with default tag.
     361 *
     362 * @returns Pointer to the allocated memory.
     363 * @returns NULL if we're out of memory.
     364 * @param   cb  Size of the memory block. Will be rounded up to page size.
     365 */
     366#define RTMemPageAllocZ(cb)             RTMemPageAllocZTag((cb), RTMEM_TAG)
     367
     368/**
     369 * Allocate zero'ed page aligned memory with custom tag.
     370 *
     371 * @returns Pointer to the allocated memory.
     372 * @returns NULL if we're out of memory.
     373 * @param   cb  Size of the memory block. Will be rounded up to page size.
     374 * @param   pszTag  Allocation tag used for statistics and such.
     375 */
     376RTDECL(void *) RTMemPageAllocZTag(size_t cb, const char *pszTag) RT_NO_THROW;
    222377
    223378/**
     
    360515
    361516/**
    362  * Same as RTMemTmpAlloc() except that it's fenced.
     517 * Same as RTMemTmpAllocTag() except that it's fenced.
    363518 *
    364519 * @returns Pointer to the allocated memory.
    365520 * @returns NULL on failure.
    366521 * @param   cb      Size in bytes of the memory block to allocate.
    367  */
    368 RTDECL(void *)  RTMemEfTmpAlloc(size_t cb, RT_SRC_POS_DECL) RT_NO_THROW;
    369 
    370 /**
    371  * Same as RTMemTmpAllocZ() except that it's fenced.
     522 * @param   pszTag  Allocation tag used for statistics and such.
     523 */
     524RTDECL(void *)  RTMemEfTmpAlloc(size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW;
     525
     526/**
     527 * Same as RTMemTmpAllocZTag() except that it's fenced.
    372528 *
    373529 * @returns Pointer to the allocated memory.
    374530 * @returns NULL on failure.
    375531 * @param   cb      Size in bytes of the memory block to allocate.
    376  */
    377 RTDECL(void *)  RTMemEfTmpAllocZ(size_t cb, RT_SRC_POS_DECL) RT_NO_THROW;
     532 * @param   pszTag  Allocation tag used for statistics and such.
     533 */
     534RTDECL(void *)  RTMemEfTmpAllocZ(size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW;
    378535
    379536/**
     
    385542
    386543/**
    387  * Same as RTMemAlloc() except that it's fenced.
     544 * Same as RTMemAllocTag() except that it's fenced.
    388545 *
    389546 * @returns Pointer to the allocated memory. Free with RTMemEfFree().
    390547 * @returns NULL on failure.
    391548 * @param   cb      Size in bytes of the memory block to allocate.
    392  */
    393 RTDECL(void *)  RTMemEfAlloc(size_t cb, RT_SRC_POS_DECL) RT_NO_THROW;
    394 
    395 /**
    396  * Same as RTMemAllocZ() except that it's fenced.
     549 * @param   pszTag  Allocation tag used for statistics and such.
     550 */
     551RTDECL(void *)  RTMemEfAlloc(size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW;
     552
     553/**
     554 * Same as RTMemAllocZTag() except that it's fenced.
    397555 *
    398556 * @returns Pointer to the allocated memory.
    399557 * @returns NULL on failure.
    400558 * @param   cb      Size in bytes of the memory block to allocate.
    401  */
    402 RTDECL(void *)  RTMemEfAllocZ(size_t cb, RT_SRC_POS_DECL) RT_NO_THROW;
    403 
    404 /**
    405  * Same as RTMemAllocVar() except that it's fenced.
     559 * @param   pszTag  Allocation tag used for statistics and such.
     560 */
     561RTDECL(void *)  RTMemEfAllocZ(size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW;
     562
     563/**
     564 * Same as RTMemAllocVarTag() except that it's fenced.
    406565 *
    407566 * @returns Pointer to the allocated memory. Free with RTMemEfFree().
    408567 * @returns NULL on failure.
    409568 * @param   cbUnaligned Size in bytes of the memory block to allocate.
    410  */
    411 RTDECL(void *)  RTMemEfAllocVar(size_t cbUnaligned, RT_SRC_POS_DECL) RT_NO_THROW;
    412 
    413 /**
    414  * Same as RTMemAllocZVar() except that it's fenced.
     569 * @param   pszTag  Allocation tag used for statistics and such.
     570 */
     571RTDECL(void *)  RTMemEfAllocVar(size_t cbUnaligned, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW;
     572
     573/**
     574 * Same as RTMemAllocZVarTag() except that it's fenced.
    415575 *
    416576 * @returns Pointer to the allocated memory.
    417577 * @returns NULL on failure.
    418578 * @param   cbUnaligned Size in bytes of the memory block to allocate.
    419  */
    420 RTDECL(void *)  RTMemEfAllocZVar(size_t cbUnaligned, RT_SRC_POS_DECL) RT_NO_THROW;
    421 
    422 /**
    423  * Same as RTMemRealloc() except that it's fenced.
     579 * @param   pszTag  Allocation tag used for statistics and such.
     580 */
     581RTDECL(void *)  RTMemEfAllocZVar(size_t cbUnaligned, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW;
     582
     583/**
     584 * Same as RTMemReallocTag() except that it's fenced.
    424585 *
    425586 * @returns Pointer to the allocated memory.
     
    427588 * @param   pvOld   The memory block to reallocate.
    428589 * @param   cbNew   The new block size (in bytes).
    429  */
    430 RTDECL(void *)  RTMemEfRealloc(void *pvOld, size_t cbNew, RT_SRC_POS_DECL) RT_NO_THROW;
     590 * @param   pszTag  Allocation tag used for statistics and such.
     591 */
     592RTDECL(void *)  RTMemEfRealloc(void *pvOld, size_t cbNew, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW;
    431593
    432594/**
     
    438600
    439601/**
    440  * Same as RTMemDup() except that it's fenced.
     602 * Same as RTMemDupTag() except that it's fenced.
    441603 *
    442604 * @returns New heap block with the duplicate data.
     
    444606 * @param   pvSrc   The memory to duplicate.
    445607 * @param   cb      The amount of memory to duplicate.
    446  */
    447 RTDECL(void *) RTMemEfDup(const void *pvSrc, size_t cb, RT_SRC_POS_DECL) RT_NO_THROW;
    448 
    449 /**
    450  * Same as RTMemEfDupEx except that it's fenced.
     608 * @param   pszTag  Allocation tag used for statistics and such.
     609 */
     610RTDECL(void *) RTMemEfDup(const void *pvSrc, size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW;
     611
     612/**
     613 * Same as RTMemEfDupExTag except that it's fenced.
    451614 *
    452615 * @returns New heap block with the duplicate data.
     
    455618 * @param   cbSrc   The amount of memory to duplicate.
    456619 * @param   cbExtra The amount of extra memory to allocate and zero.
    457  */
    458 RTDECL(void *) RTMemEfDupEx(const void *pvSrc, size_t cbSrc, size_t cbExtra, RT_SRC_POS_DECL) RT_NO_THROW;
     620 * @param   pszTag  Allocation tag used for statistics and such.
     621 */
     622RTDECL(void *) RTMemEfDupEx(const void *pvSrc, size_t cbSrc, size_t cbExtra, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW;
    459623
    460624/** @def RTMEM_WRAP_TO_EF_APIS
     
    462626 */
    463627#if defined(RTMEM_WRAP_TO_EF_APIS) && defined(IN_RING3) && !defined(RTMEM_NO_WRAP_TO_EF_APIS)
    464 # define RTMemTmpAlloc(cb)                  RTMemEfTmpAlloc((cb), RT_SRC_POS)
    465 # define RTMemTmpAllocZ(cb)                 RTMemEfTmpAllocZ((cb), RT_SRC_POS)
    466 # define RTMemTmpFree(pv)                   RTMemEfTmpFree((pv), RT_SRC_POS)
    467 # define RTMemAlloc(cb)                     RTMemEfAlloc((cb), RT_SRC_POS)
    468 # define RTMemAllocZ(cb)                    RTMemEfAllocZ((cb), RT_SRC_POS)
    469 # define RTMemAllocVar(cbUnaligned)         RTMemEfAllocVar((cbUnaligned), RT_SRC_POS)
    470 # define RTMemAllocZVar(cbUnaligned)        RTMemEfAllocZVar((cbUnaligned), RT_SRC_POS)
    471 # define RTMemRealloc(pvOld, cbNew)         RTMemEfRealloc((pvOld), (cbNew), RT_SRC_POS)
    472 # define RTMemFree(pv)                      RTMemEfFree((pv), RT_SRC_POS)
    473 # define RTMemDup(pvSrc, cb)                RTMemEfDup((pvSrc), (cb), RT_SRC_POS)
    474 # define RTMemDupEx(pvSrc, cbSrc, cbExtra)  RTMemEfDupEx((pvSrc), (cbSrc), (cbExtra), RT_SRC_POS)
     628# define RTMemTmpAllocTag(cb, pszTag)                   RTMemEfTmpAlloc((cb), (pszTag), RT_SRC_POS)
     629# define RTMemTmpAllocZTag(cb, pszTag)                  RTMemEfTmpAllocZ((cb), (pszTag), RT_SRC_POS)
     630# define RTMemTmpFree(pv)                               RTMemEfTmpFree((pv), RT_SRC_POS)
     631# define RTMemAllocTag(cb, pszTag)                      RTMemEfAlloc((cb), (pszTag), RT_SRC_POS)
     632# define RTMemAllocZTag(cb, pszTag)                     RTMemEfAllocZ((cb), (pszTag), RT_SRC_POS)
     633# define RTMemAllocVarTag(cbUnaligned, pszTag)          RTMemEfAllocVar((cbUnaligned), (pszTag), RT_SRC_POS)
     634# define RTMemAllocZVarTag(cbUnaligned, pszTag)         RTMemEfAllocZVar((cbUnaligned), (pszTag), RT_SRC_POS)
     635# define RTMemReallocTag(pvOld, cbNew, pszTag)          RTMemEfRealloc((pvOld), (cbNew), (pszTag), RT_SRC_POS)
     636# define RTMemFree(pv)                                  RTMemEfFree((pv), RT_SRC_POS)
     637# define RTMemDupTag(pvSrc, cb, pszTag)                 RTMemEfDup((pvSrc), (cb), (pszTag), RT_SRC_POS)
     638# define RTMemDupExTag(pvSrc, cbSrc, cbExtra, pszTag)   RTMemEfDupEx((pvSrc), (cbSrc), (cbExtra), (pszTag), RT_SRC_POS)
    475639#endif
    476640#ifdef DOXYGEN_RUNNING
     
    479643
    480644/**
    481  * Fenced drop-in replacement for RTMemTmpAlloc.
    482  * @copydoc RTMemTmpAlloc
    483  */
    484 RTDECL(void *)  RTMemEfTmpAllocNP(size_t cb) RT_NO_THROW;
    485 
    486 /**
    487  * Fenced drop-in replacement for RTMemTmpAllocZ.
    488  * @copydoc RTMemTmpAllocZ
    489  */
    490 RTDECL(void *)  RTMemEfTmpAllocZNP(size_t cb) RT_NO_THROW;
    491 
    492 /**
    493  * Fenced drop-in replacement for RTMemTmpFree.
    494  * @copydoc RTMemTmpFree
     645 * Fenced drop-in replacement for RTMemTmpAllocTag.
     646 * @copydoc RTMemTmpAllocTag
     647 */
     648RTDECL(void *)  RTMemEfTmpAllocNP(size_t cb, const char *pszTag) RT_NO_THROW;
     649
     650/**
     651 * Fenced drop-in replacement for RTMemTmpAllocZTag.
     652 * @copydoc RTMemTmpAllocZTag
     653 */
     654RTDECL(void *)  RTMemEfTmpAllocZNP(size_t cb, const char *pszTag) RT_NO_THROW;
     655
     656/**
     657 * Fenced drop-in replacement for RTMemTmpFreeTag.
     658 * @copydoc RTMemTmpFreeTag
    495659 */
    496660RTDECL(void)    RTMemEfTmpFreeNP(void *pv) RT_NO_THROW;
    497661
    498662/**
    499  * Fenced drop-in replacement for RTMemAlloc.
    500  * @copydoc RTMemAlloc
    501  */
    502 RTDECL(void *)  RTMemEfAllocNP(size_t cb) RT_NO_THROW;
    503 
    504 /**
    505  * Fenced drop-in replacement for RTMemAllocZ.
    506  * @copydoc RTMemAllocZ
    507  */
    508 RTDECL(void *)  RTMemEfAllocZNP(size_t cb) RT_NO_THROW;
    509 
    510 /**
    511  * Fenced drop-in replacement for RTMemAllocVar
    512  * @copydoc RTMemAllocVar
    513  */
    514 RTDECL(void *)  RTMemEfAllocVarNP(size_t cbUnaligned) RT_NO_THROW;
    515 
    516 /**
    517  * Fenced drop-in replacement for RTMemAllocZVar.
    518  * @copydoc RTMemAllocZVar
    519  */
    520 RTDECL(void *)  RTMemEfAllocZVarNP(size_t cbUnaligned) RT_NO_THROW;
    521 
    522 /**
    523  * Fenced drop-in replacement for RTMemRealloc.
    524  * @copydoc RTMemRealloc
    525  */
    526 RTDECL(void *)  RTMemEfReallocNP(void *pvOld, size_t cbNew) RT_NO_THROW;
     663 * Fenced drop-in replacement for RTMemAllocTag.
     664 * @copydoc RTMemAllocTag
     665 */
     666RTDECL(void *)  RTMemEfAllocNP(size_t cb, const char *pszTag) RT_NO_THROW;
     667
     668/**
     669 * Fenced drop-in replacement for RTMemAllocZTag.
     670 * @copydoc RTMemAllocZTag
     671 */
     672RTDECL(void *)  RTMemEfAllocZNP(size_t cb, const char *pszTag) RT_NO_THROW;
     673
     674/**
     675 * Fenced drop-in replacement for RTMemAllocVarTag
     676 * @copydoc RTMemAllocVarTag
     677 */
     678RTDECL(void *)  RTMemEfAllocVarNP(size_t cbUnaligned, const char *pszTag) RT_NO_THROW;
     679
     680/**
     681 * Fenced drop-in replacement for RTMemAllocZVarTag.
     682 * @copydoc RTMemAllocZVarTag
     683 */
     684RTDECL(void *)  RTMemEfAllocZVarNP(size_t cbUnaligned, const char *pszTag) RT_NO_THROW;
     685
     686/**
     687 * Fenced drop-in replacement for RTMemReallocTag.
     688 * @copydoc RTMemReallocTag
     689 */
     690RTDECL(void *)  RTMemEfReallocNP(void *pvOld, size_t cbNew, const char *pszTag) RT_NO_THROW;
    527691
    528692/**
     
    533697
    534698/**
    535  * Fenced drop-in replacement for RTMemDupEx.
    536  * @copydoc RTMemDupEx
    537  */
    538 RTDECL(void *) RTMemEfDupNP(const void *pvSrc, size_t cb) RT_NO_THROW;
    539 
    540 /**
    541  * Fenced drop-in replacement for RTMemDupEx.
    542  * @copydoc RTMemDupEx
    543  */
    544 RTDECL(void *) RTMemEfDupExNP(const void *pvSrc, size_t cbSrc, size_t cbExtra) RT_NO_THROW;
     699 * Fenced drop-in replacement for RTMemDupExTag.
     700 * @copydoc RTMemDupExTag
     701 */
     702RTDECL(void *) RTMemEfDupNP(const void *pvSrc, size_t cb, const char *pszTag) RT_NO_THROW;
     703
     704/**
     705 * Fenced drop-in replacement for RTMemDupExTag.
     706 * @copydoc RTMemDupExTag
     707 */
     708RTDECL(void *) RTMemEfDupExNP(const void *pvSrc, size_t cbSrc, size_t cbExtra, const char *pszTag) RT_NO_THROW;
    545709
    546710/** @} */
     
    655819          void Destruct(T *) = RTMemAutoDestructor<T>,
    656820# ifdef RTMEM_WRAP_TO_EF_APIS
    657           void *Allocator(void *, size_t) = RTMemEfReallocNP
     821          void *Allocator(void *, size_t, const char *) = RTMemEfReallocNP
    658822# else
    659           void *Allocator(void *, size_t) = RTMemRealloc
     823          void *Allocator(void *, size_t, const char *) = RTMemReallocTag
    660824# endif
    661825          >
     
    682846     */
    683847    RTMemAutoPtr(size_t a_cElements, bool a_fZeroed = false)
    684         : RTAutoRes<T *, Destruct, RTMemAutoNil<T> >((T *)Allocator(NULL, a_cElements * sizeof(T)))
     848        : RTAutoRes<T *, Destruct, RTMemAutoNil<T> >((T *)Allocator(NULL, a_cElements * sizeof(T), RTMEM_TAG))
    685849    {
    686850        if (a_fZeroed && RT_LIKELY(this->get() != NULL))
     
    744908    {
    745909        this->reset(NULL);
    746         T *pNewMem = (T *)Allocator(NULL, a_cElements * sizeof(T));
     910        T *pNewMem = (T *)Allocator(NULL, a_cElements * sizeof(T), RTMEM_TAG);
    747911        if (a_fZeroed && RT_LIKELY(pNewMem != NULL))
    748912            memset(pNewMem, '\0', a_cElements * sizeof(T));
     
    771935    bool realloc(size_t a_cElements = 1)
    772936    {
    773         T *aNewValue = (T *)Allocator(this->get(), a_cElements * sizeof(T));
     937        T *aNewValue = (T *)Allocator(this->get(), a_cElements * sizeof(T), RTMEM_TAG);
    774938        if (RT_LIKELY(aNewValue != NULL))
    775939            this->release();
  • trunk/include/iprt/memobj.h

    r29027 r31157  
    44
    55/*
    6  * Copyright (C) 2006-2007 Oracle Corporation
     6 * Copyright (C) 2006-2010 Oracle Corporation
    77 *
    88 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3737 */
    3838
     39/** @def RTMEM_TAG
     40 * The default allocation tag used by the RTMem allocation APIs.
     41 *
     42 * When not defined before the inclusion of iprt/memobj.h or iprt/mem.h, this
     43 * will default to the pointer to the current file name.  The memory API will
     44 * make of use of this as pointer to a volatile but read-only string.
     45 */
     46#ifndef RTMEM_TAG
     47# define RTMEM_TAG   (__FILE__)
     48#endif
     49
    3950#ifdef IN_RING0
    4051
     
    102113
    103114/**
    104  * Allocates page aligned virtual kernel memory.
     115 * Allocates page aligned virtual kernel memory (default tag).
    105116 *
    106117 * The memory is taken from a non paged (= fixed physical memory backing) pool.
     
    111122 * @param   fExecutable     Flag indicating whether it should be permitted to executed code in the memory object.
    112123 */
    113 RTR0DECL(int) RTR0MemObjAllocPage(PRTR0MEMOBJ pMemObj, size_t cb, bool fExecutable);
    114 
    115 /**
    116  * Allocates page aligned virtual kernel memory with physical backing below 4GB.
     124#define RTR0MemObjAllocPage(pMemObj, cb, fExecutable) \
     125    RTR0MemObjAllocPageTag((pMemObj), (cb), (fExecutable), RTMEM_TAG)
     126
     127/**
     128 * Allocates page aligned virtual kernel memory (custom tag).
     129 *
     130 * The memory is taken from a non paged (= fixed physical memory backing) pool.
     131 *
     132 * @returns IPRT status code.
     133 * @param   pMemObj         Where to store the ring-0 memory object handle.
     134 * @param   cb              Number of bytes to allocate. This is rounded up to nearest page.
     135 * @param   fExecutable     Flag indicating whether it should be permitted to executed code in the memory object.
     136 * @param   pszTag          Allocation tag used for statistics and such.
     137 */
     138RTR0DECL(int) RTR0MemObjAllocPageTag(PRTR0MEMOBJ pMemObj, size_t cb, bool fExecutable, const char *pszTag);
     139
     140/**
     141 * Allocates page aligned virtual kernel memory with physical backing below 4GB
     142 * (default tag).
    117143 *
    118144 * The physical memory backing the allocation is fixed.
     
    123149 * @param   fExecutable     Flag indicating whether it should be permitted to executed code in the memory object.
    124150 */
    125 RTR0DECL(int) RTR0MemObjAllocLow(PRTR0MEMOBJ pMemObj, size_t cb, bool fExecutable);
    126 
    127 /**
    128  * Allocates page aligned virtual kernel memory with contiguous physical backing below 4GB.
     151#define RTR0MemObjAllocLow(pMemObj, cb, fExecutable) \
     152    RTR0MemObjAllocLowTag((pMemObj), (cb), (fExecutable), RTMEM_TAG)
     153
     154/**
     155 * Allocates page aligned virtual kernel memory with physical backing below 4GB
     156 * (custom tag).
    129157 *
    130158 * The physical memory backing the allocation is fixed.
     
    134162 * @param   cb              Number of bytes to allocate. This is rounded up to nearest page.
    135163 * @param   fExecutable     Flag indicating whether it should be permitted to executed code in the memory object.
    136  */
    137 RTR0DECL(int) RTR0MemObjAllocCont(PRTR0MEMOBJ pMemObj, size_t cb, bool fExecutable);
    138 
    139 /**
    140  * Locks a range of user virtual memory.
     164 * @param   pszTag          Allocation tag used for statistics and such.
     165 */
     166RTR0DECL(int) RTR0MemObjAllocLowTag(PRTR0MEMOBJ pMemObj, size_t cb, bool fExecutable, const char *pszTag);
     167
     168/**
     169 * Allocates page aligned virtual kernel memory with contiguous physical backing
     170 * below 4GB (default tag).
     171 *
     172 * The physical memory backing the allocation is fixed.
     173 *
     174 * @returns IPRT status code.
     175 * @param   pMemObj         Where to store the ring-0 memory object handle.
     176 * @param   cb              Number of bytes to allocate. This is rounded up to nearest page.
     177 * @param   fExecutable     Flag indicating whether it should be permitted to executed code in the memory object.
     178 */
     179#define RTR0MemObjAllocCont(pMemObj, cb, fExecutable) \
     180    RTR0MemObjAllocContTag((pMemObj), (cb), (fExecutable), RTMEM_TAG)
     181
     182/**
     183 * Allocates page aligned virtual kernel memory with contiguous physical backing
     184 * below 4GB (custom tag).
     185 *
     186 * The physical memory backing the allocation is fixed.
     187 *
     188 * @returns IPRT status code.
     189 * @param   pMemObj         Where to store the ring-0 memory object handle.
     190 * @param   cb              Number of bytes to allocate. This is rounded up to nearest page.
     191 * @param   fExecutable     Flag indicating whether it should be permitted to executed code in the memory object.
     192 * @param   pszTag          Allocation tag used for statistics and such.
     193 */
     194RTR0DECL(int) RTR0MemObjAllocContTag(PRTR0MEMOBJ pMemObj, size_t cb, bool fExecutable, const char *pszTag);
     195
     196/**
     197 * Locks a range of user virtual memory (default tag).
    141198 *
    142199 * @returns IPRT status code.
     
    159216 *          lifting it.
    160217 */
    161 RTR0DECL(int) RTR0MemObjLockUser(PRTR0MEMOBJ pMemObj, RTR3PTR R3Ptr, size_t cb, uint32_t fAccess, RTR0PROCESS R0Process);
    162 
    163 /**
    164  * Locks a range of kernel virtual memory.
     218#define RTR0MemObjLockUser(pMemObj, R3Ptr, cb, fAccess, R0Process) \
     219    RTR0MemObjLockUserTag((pMemObj), (R3Ptr), (cb), (fAccess), (R0Process), RTMEM_TAG)
     220
     221/**
     222 * Locks a range of user virtual memory (custom tag).
     223 *
     224 * @returns IPRT status code.
     225 * @param   pMemObj         Where to store the ring-0 memory object handle.
     226 * @param   R3Ptr           User virtual address. This is rounded down to a page
     227 *                          boundrary.
     228 * @param   cb              Number of bytes to lock. This is rounded up to
     229 *                          nearest page boundrary.
     230 * @param   fAccess         The desired access, a combination of RTMEM_PROT_READ
     231 *                          and RTMEM_PROT_WRITE.
     232 * @param   R0Process       The process to lock pages in. NIL_R0PROCESS is an
     233 *                          alias for the current one.
     234 * @param   pszTag          Allocation tag used for statistics and such.
     235 *
     236 * @remarks RTR0MemGetAddressR3() and RTR0MemGetAddress() will return therounded
     237 *          down address.
     238 *
     239 * @remarks Linux: This API requires that the memory begin locked is in a memory
     240 *          mapping that is not required in any forked off child process. This
     241 *          is not intented as permanent restriction, feel free to help out
     242 *          lifting it.
     243 */
     244RTR0DECL(int) RTR0MemObjLockUserTag(PRTR0MEMOBJ pMemObj, RTR3PTR R3Ptr, size_t cb, uint32_t fAccess,
     245                                    RTR0PROCESS R0Process, const char *pszTag);
     246
     247/**
     248 * Locks a range of kernel virtual memory (default tag).
    165249 *
    166250 * @returns IPRT status code.
     
    173257 * @remark  RTR0MemGetAddress() will return the rounded down address.
    174258 */
    175 RTR0DECL(int) RTR0MemObjLockKernel(PRTR0MEMOBJ pMemObj, void *pv, size_t cb, uint32_t fAccess);
    176 
    177 /**
    178  * Allocates contiguous page aligned physical memory without (necessarily) any kernel mapping.
     259#define RTR0MemObjLockKernel(pMemObj, pv, cb, fAccess) \
     260    RTR0MemObjLockKernelTag((pMemObj), (pv), (cb), (fAccess), RTMEM_TAG)
     261
     262/**
     263 * Locks a range of kernel virtual memory (custom tag).
     264 *
     265 * @returns IPRT status code.
     266 * @param   pMemObj         Where to store the ring-0 memory object handle.
     267 * @param   pv              Kernel virtual address. This is rounded down to a page boundrary.
     268 * @param   cb              Number of bytes to lock. This is rounded up to nearest page boundrary.
     269 * @param   fAccess         The desired access, a combination of RTMEM_PROT_READ
     270 *                          and RTMEM_PROT_WRITE.
     271 * @param   pszTag          Allocation tag used for statistics and such.
     272 *
     273 * @remark  RTR0MemGetAddress() will return the rounded down address.
     274 */
     275RTR0DECL(int) RTR0MemObjLockKernelTag(PRTR0MEMOBJ pMemObj, void *pv, size_t cb, uint32_t fAccess, const char *pszTag);
     276
     277/**
     278 * Allocates contiguous page aligned physical memory without (necessarily) any
     279 * kernel mapping (default tag).
    179280 *
    180281 * @returns IPRT status code.
     
    184285 *                          Pass NIL_RTHCPHYS if any address is acceptable.
    185286 */
    186 RTR0DECL(int) RTR0MemObjAllocPhys(PRTR0MEMOBJ pMemObj, size_t cb, RTHCPHYS PhysHighest);
    187 
    188 /**
    189  * Allocates contiguous physical memory without (necessarily) any kernel mapping.
     287#define RTR0MemObjAllocPhys(pMemObj, cb, PhysHighest) \
     288    RTR0MemObjAllocPhysTag((pMemObj), (cb), (PhysHighest), RTMEM_TAG)
     289
     290/**
     291 * Allocates contiguous page aligned physical memory without (necessarily) any
     292 * kernel mapping (custom tag).
    190293 *
    191294 * @returns IPRT status code.
     
    194297 * @param   PhysHighest     The highest permittable address (inclusive).
    195298 *                          Pass NIL_RTHCPHYS if any address is acceptable.
     299 * @param   pszTag          Allocation tag used for statistics and such.
     300 */
     301RTR0DECL(int) RTR0MemObjAllocPhysTag(PRTR0MEMOBJ pMemObj, size_t cb, RTHCPHYS PhysHighest, const char *pszTag);
     302
     303/**
     304 * Allocates contiguous physical memory without (necessarily) any kernel mapping
     305 * (default tag).
     306 *
     307 * @returns IPRT status code.
     308 * @param   pMemObj         Where to store the ring-0 memory object handle.
     309 * @param   cb              Number of bytes to allocate. This is rounded up to nearest page.
     310 * @param   PhysHighest     The highest permittable address (inclusive).
     311 *                          Pass NIL_RTHCPHYS if any address is acceptable.
    196312 * @param   uAlignment      The alignment of the reserved memory.
    197313 *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M, _4M and _1G.
    198314 */
    199 RTR0DECL(int) RTR0MemObjAllocPhysEx(PRTR0MEMOBJ pMemObj, size_t cb, RTHCPHYS PhysHighest, size_t uAlignment);
    200 
    201 /**
    202  * Allocates non-contiguous page aligned physical memory without (necessarily) any kernel mapping.
     315#define RTR0MemObjAllocPhysEx(pMemObj, cb, PhysHighest, uAlignment) \
     316    RTR0MemObjAllocPhysExTag((pMemObj), (cb), (PhysHighest), (uAlignment), RTMEM_TAG)
     317
     318/**
     319 * Allocates contiguous physical memory without (necessarily) any kernel mapping
     320 * (custom tag).
     321 *
     322 * @returns IPRT status code.
     323 * @param   pMemObj         Where to store the ring-0 memory object handle.
     324 * @param   cb              Number of bytes to allocate. This is rounded up to nearest page.
     325 * @param   PhysHighest     The highest permittable address (inclusive).
     326 *                          Pass NIL_RTHCPHYS if any address is acceptable.
     327 * @param   uAlignment      The alignment of the reserved memory.
     328 *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M, _4M and _1G.
     329 * @param   pszTag          Allocation tag used for statistics and such.
     330 */
     331RTR0DECL(int) RTR0MemObjAllocPhysExTag(PRTR0MEMOBJ pMemObj, size_t cb, RTHCPHYS PhysHighest, size_t uAlignment, const char *pszTag);
     332
     333/**
     334 * Allocates non-contiguous page aligned physical memory without (necessarily)
     335 * any kernel mapping (default tag).
    203336 *
    204337 * This API is for allocating huge amounts of pages and will return
     
    216349 *                          Pass NIL_RTHCPHYS if any address is acceptable.
    217350 */
    218 RTR0DECL(int) RTR0MemObjAllocPhysNC(PRTR0MEMOBJ pMemObj, size_t cb, RTHCPHYS PhysHighest);
     351#define RTR0MemObjAllocPhysNC(pMemObj, cb, PhysHighest) \
     352    RTR0MemObjAllocPhysNCTag((pMemObj), (cb), (PhysHighest), RTMEM_TAG)
     353
     354/**
     355 * Allocates non-contiguous page aligned physical memory without (necessarily)
     356 * any kernel mapping (custom tag).
     357 *
     358 * This API is for allocating huge amounts of pages and will return
     359 * VERR_NOT_SUPPORTED if this cannot be implemented in a satisfactory
     360 * manner.
     361 *
     362 * @returns IPRT status code.
     363 * @retval  VERR_NOT_SUPPORTED if it's not possible to allocated unmapped
     364 *          physical memory on this platform. The caller should expect
     365 *          this error and have a fallback strategy for it.
     366 *
     367 * @param   pMemObj         Where to store the ring-0 memory object handle.
     368 * @param   cb              Number of bytes to allocate. This is rounded up to nearest page.
     369 * @param   PhysHighest     The highest permittable address (inclusive).
     370 *                          Pass NIL_RTHCPHYS if any address is acceptable.
     371 * @param   pszTag          Allocation tag used for statistics and such.
     372 */
     373RTR0DECL(int) RTR0MemObjAllocPhysNCTag(PRTR0MEMOBJ pMemObj, size_t cb, RTHCPHYS PhysHighest, const char *pszTag);
    219374
    220375/** Memory cache policy for RTR0MemObjEnterPhys.
     
    228383
    229384/**
    230  * Creates a page aligned, contiguous, physical memory object.
     385 * Creates a page aligned, contiguous, physical memory object (default tag).
    231386 *
    232387 * No physical memory is allocated, we trust you do know what you're doing.
     
    239394 * @param   uCachePolicy    One of the RTMEM_CACHE_XXX modes.
    240395 */
    241 RTR0DECL(int) RTR0MemObjEnterPhys(PRTR0MEMOBJ pMemObj, RTHCPHYS Phys, size_t cb, uint32_t uCachePolicy);
    242 
    243 /**
    244  * Reserves kernel virtual address space.
     396#define RTR0MemObjEnterPhys(pMemObj, Phys, cb, uCachePolicy) \
     397    RTR0MemObjEnterPhysTag((pMemObj), (Phys), (cb), (uCachePolicy), RTMEM_TAG)
     398
     399/**
     400 * Creates a page aligned, contiguous, physical memory object (custom tag).
     401 *
     402 * No physical memory is allocated, we trust you do know what you're doing.
     403 *
     404 * @returns IPRT status code.
     405 * @param   pMemObj         Where to store the ring-0 memory object handle.
     406 * @param   Phys            The physical address to start at. This is rounded down to the
     407 *                          nearest page boundrary.
     408 * @param   cb              The size of the object in bytes. This is rounded up to nearest page boundrary.
     409 * @param   uCachePolicy    One of the RTMEM_CACHE_XXX modes.
     410 * @param   pszTag          Allocation tag used for statistics and such.
     411 */
     412RTR0DECL(int) RTR0MemObjEnterPhysTag(PRTR0MEMOBJ pMemObj, RTHCPHYS Phys, size_t cb, uint32_t uCachePolicy, const char *pszTag);
     413
     414/**
     415 * Reserves kernel virtual address space (default tag).
    245416 *
    246417 * If this function fails with VERR_NOT_SUPPORTED, the idea is that you
     
    255426 *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M and _4M.
    256427 */
    257 RTR0DECL(int) RTR0MemObjReserveKernel(PRTR0MEMOBJ pMemObj, void *pvFixed, size_t cb, size_t uAlignment);
    258 
    259 /**
    260  * Reserves user virtual address space in the current process.
     428#define RTR0MemObjReserveKernel(pMemObj, pvFixed, cb, uAlignment) \
     429    RTR0MemObjReserveKernelTag((pMemObj), (pvFixed), (cb), (uAlignment), RTMEM_TAG)
     430
     431/**
     432 * Reserves kernel virtual address space (custom tag).
     433 *
     434 * If this function fails with VERR_NOT_SUPPORTED, the idea is that you
     435 * can use RTR0MemObjEnterPhys() + RTR0MemObjMapKernel() as a fallback if
     436 * you have a safe physical address range to make use of...
     437 *
     438 * @returns IPRT status code.
     439 * @param   pMemObj         Where to store the ring-0 memory object handle.
     440 * @param   pvFixed         Requested address. (void *)-1 means any address. This must match the alignment.
     441 * @param   cb              The number of bytes to reserve. This is rounded up to nearest page.
     442 * @param   uAlignment      The alignment of the reserved memory.
     443 *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M and _4M.
     444 * @param   pszTag          Allocation tag used for statistics and such.
     445 */
     446RTR0DECL(int) RTR0MemObjReserveKernelTag(PRTR0MEMOBJ pMemObj, void *pvFixed, size_t cb, size_t uAlignment, const char *pszTag);
     447
     448/**
     449 * Reserves user virtual address space in the current process (default tag).
    261450 *
    262451 * @returns IPRT status code.
     
    268457 * @param   R0Process       The process to reserve the memory in. NIL_R0PROCESS is an alias for the current one.
    269458 */
    270 RTR0DECL(int) RTR0MemObjReserveUser(PRTR0MEMOBJ pMemObj, RTR3PTR R3PtrFixed, size_t cb, size_t uAlignment, RTR0PROCESS R0Process);
    271 
    272 /**
    273  * Maps a memory object into kernel virtual address space.
     459#define RTR0MemObjReserveUser(pMemObj, R3PtrFixed, cb, uAlignment, R0Process) \
     460    RTR0MemObjReserveUserTag((pMemObj), (R3PtrFixed), (cb), (uAlignment), (R0Process), RTMEM_TAG)
     461
     462/**
     463 * Reserves user virtual address space in the current process (custom tag).
     464 *
     465 * @returns IPRT status code.
     466 * @param   pMemObj         Where to store the ring-0 memory object handle.
     467 * @param   R3PtrFixed      Requested address. (RTR3PTR)-1 means any address. This must match the alignment.
     468 * @param   cb              The number of bytes to reserve. This is rounded up to nearest PAGE_SIZE.
     469 * @param   uAlignment      The alignment of the reserved memory.
     470 *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M and _4M.
     471 * @param   R0Process       The process to reserve the memory in. NIL_R0PROCESS is an alias for the current one.
     472 * @param   pszTag          Allocation tag used for statistics and such.
     473 */
     474RTR0DECL(int) RTR0MemObjReserveUserTag(PRTR0MEMOBJ pMemObj, RTR3PTR R3PtrFixed, size_t cb, size_t uAlignment,
     475                                       RTR0PROCESS R0Process, const char *pszTag);
     476
     477/**
     478 * Maps a memory object into kernel virtual address space (default tag).
    274479 *
    275480 * This is the same as calling RTR0MemObjMapKernelEx with cbSub and offSub set
     
    284489 * @param   fProt           Combination of RTMEM_PROT_* flags (except RTMEM_PROT_NONE).
    285490 */
    286 RTR0DECL(int) RTR0MemObjMapKernel(PRTR0MEMOBJ pMemObj, RTR0MEMOBJ MemObjToMap, void *pvFixed, size_t uAlignment, unsigned fProt);
    287 
    288 /**
    289  * Maps a memory object into kernel virtual address space.
     491#define RTR0MemObjMapKernel(pMemObj, MemObjToMap, pvFixed, uAlignment, fProt) \
     492    RTR0MemObjMapKernelTag((pMemObj), (MemObjToMap), (pvFixed), (uAlignment), (fProt), RTMEM_TAG)
     493
     494/**
     495 * Maps a memory object into kernel virtual address space (custom tag).
     496 *
     497 * This is the same as calling RTR0MemObjMapKernelEx with cbSub and offSub set
     498 * to zero.
     499 *
     500 * @returns IPRT status code.
     501 * @param   pMemObj         Where to store the ring-0 memory object handle of the mapping object.
     502 * @param   MemObjToMap     The object to be map.
     503 * @param   pvFixed         Requested address. (void *)-1 means any address. This must match the alignment.
     504 * @param   uAlignment      The alignment of the reserved memory.
     505 *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M and _4M.
     506 * @param   fProt           Combination of RTMEM_PROT_* flags (except RTMEM_PROT_NONE).
     507 * @param   pszTag          Allocation tag used for statistics and such.
     508 */
     509RTR0DECL(int) RTR0MemObjMapKernelTag(PRTR0MEMOBJ pMemObj, RTR0MEMOBJ MemObjToMap, void *pvFixed,
     510                                     size_t uAlignment, unsigned fProt, const char *pszTag);
     511
     512/**
     513 * Maps a memory object into kernel virtual address space (default tag).
    290514 *
    291515 * The ability to map subsections of the object into kernel space is currently
     
    310534 *                          page aligned.
    311535 */
    312 RTR0DECL(int) RTR0MemObjMapKernelEx(PRTR0MEMOBJ pMemObj, RTR0MEMOBJ MemObjToMap, void *pvFixed, size_t uAlignment,
    313                                     unsigned fProt, size_t offSub, size_t cbSub);
    314 
    315 /**
    316  * Maps a memory object into user virtual address space in the current process.
     536#define RTR0MemObjMapKernelEx(pMemObj, MemObjToMap, pvFixed, uAlignment, fProt, offSub, cbSub) \
     537    RTR0MemObjMapKernelExTag((pMemObj), (MemObjToMap), (pvFixed), (uAlignment), (fProt), (offSub), (cbSub), RTMEM_TAG)
     538
     539/**
     540 * Maps a memory object into kernel virtual address space (custom tag).
     541 *
     542 * The ability to map subsections of the object into kernel space is currently
     543 * not implemented on all platforms. All/Most of platforms supports mapping the
     544 * whole object into  kernel space.
     545 *
     546 * @returns IPRT status code.
     547 * @retval  VERR_NOT_SUPPORTED if it's not possible to map a subsection of a
     548 *          memory object on this platform. When you hit this, try implement it.
     549 *
     550 * @param   pMemObj         Where to store the ring-0 memory object handle of the mapping object.
     551 * @param   MemObjToMap     The object to be map.
     552 * @param   pvFixed         Requested address. (void *)-1 means any address. This must match the alignment.
     553 * @param   uAlignment      The alignment of the reserved memory.
     554 *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M and _4M.
     555 * @param   fProt           Combination of RTMEM_PROT_* flags (except RTMEM_PROT_NONE).
     556 * @param   offSub          Where in the object to start mapping. If non-zero
     557 *                          the value must be page aligned and cbSub must be
     558 *                          non-zero as well.
     559 * @param   cbSub           The size of the part of the object to be mapped. If
     560 *                          zero the entire object is mapped. The value must be
     561 *                          page aligned.
     562 * @param   pszTag          Allocation tag used for statistics and such.
     563 */
     564RTR0DECL(int) RTR0MemObjMapKernelExTag(PRTR0MEMOBJ pMemObj, RTR0MEMOBJ MemObjToMap, void *pvFixed, size_t uAlignment,
     565                                       unsigned fProt, size_t offSub, size_t cbSub, const char *pszTag);
     566
     567/**
     568 * Maps a memory object into user virtual address space in the current process
     569 * (default tag).
    317570 *
    318571 * @returns IPRT status code.
     
    325578 * @param   R0Process       The process to map the memory into. NIL_R0PROCESS is an alias for the current one.
    326579 */
    327 RTR0DECL(int) RTR0MemObjMapUser(PRTR0MEMOBJ pMemObj, RTR0MEMOBJ MemObjToMap, RTR3PTR R3PtrFixed, size_t uAlignment, unsigned fProt, RTR0PROCESS R0Process);
     580#define RTR0MemObjMapUser(pMemObj, MemObjToMap, R3PtrFixed, uAlignment, fProt, R0Process) \
     581    RTR0MemObjMapUserTag((pMemObj), (MemObjToMap), (R3PtrFixed), (uAlignment), (fProt), (R0Process), RTMEM_TAG)
     582
     583/**
     584 * Maps a memory object into user virtual address space in the current process
     585 * (custom tag).
     586 *
     587 * @returns IPRT status code.
     588 * @param   pMemObj         Where to store the ring-0 memory object handle of the mapping object.
     589 * @param   MemObjToMap     The object to be map.
     590 * @param   R3PtrFixed      Requested address. (RTR3PTR)-1 means any address. This must match the alignment.
     591 * @param   uAlignment      The alignment of the reserved memory.
     592 *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M and _4M.
     593 * @param   fProt           Combination of RTMEM_PROT_* flags (except RTMEM_PROT_NONE).
     594 * @param   R0Process       The process to map the memory into. NIL_R0PROCESS is an alias for the current one.
     595 * @param   pszTag          Allocation tag used for statistics and such.
     596 */
     597RTR0DECL(int) RTR0MemObjMapUserTag(PRTR0MEMOBJ pMemObj, RTR0MEMOBJ MemObjToMap, RTR3PTR R3PtrFixed,
     598                                   size_t uAlignment, unsigned fProt, RTR0PROCESS R0Process, const char *pszTag);
    328599
    329600/**
  • trunk/include/iprt/string.h

    r30859 r31157  
    44
    55/*
    6  * Copyright (C) 2006-2007 Oracle Corporation
     6 * Copyright (C) 2006-2010 Oracle Corporation
    77 *
    88 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    115115
    116116
     117/** @def RTMEM_TAG
     118 * The default allocation tag used by the RTStr allocation APIs.
     119 *
     120 * When not defined before the inclusion of iprt/string.h, this will default to
     121 * the pointer to the current file name.  The string API will make of use of
     122 * this as pointer to a volatile but read-only string.
     123 */
     124#ifndef RTSTR_TAG
     125# define RTSTR_TAG      (__FILE__)
     126#endif
     127
     128
    117129#ifdef IN_RING3
    118130
    119131/**
    120  * Allocates tmp buffer, translates pszString from UTF8 to current codepage.
     132 * Allocates tmp buffer with default tag, translates pszString from UTF8 to
     133 * current codepage.
    121134 *
    122135 * @returns iprt status code.
     
    125138 * @param   pszString       UTF-8 string to convert.
    126139 */
    127 RTR3DECL(int)  RTStrUtf8ToCurrentCP(char **ppszString, const char *pszString);
     140#define RTStrUtf8ToCurrentCP(ppszString, pszString)     RTStrUtf8ToCurrentCPTag((ppszString), (pszString), RTSTR_TAG)
     141
     142/**
     143 * Allocates tmp buffer with custom tag, translates pszString from UTF8 to
     144 * current codepage.
     145 *
     146 * @returns iprt status code.
     147 * @param   ppszString      Receives pointer of allocated native CP string.
     148 *                          The returned pointer must be freed using
     149 *                          RTStrFree()., const char *pszTag
     150 * @param   pszString       UTF-8 string to convert.
     151 * @param   pszTag          Allocation tag used for statistics and such.
     152 */
     153RTR3DECL(int)  RTStrUtf8ToCurrentCPTag(char **ppszString, const char *pszString, const char *pszTag);
    128154
    129155/**
     
    135161 * @param   pszString       Native string to convert.
    136162 */
    137 RTR3DECL(int)  RTStrCurrentCPToUtf8(char **ppszString, const char *pszString);
    138 
    139 #endif
     163#define RTStrCurrentCPToUtf8(ppszString, pszString)     RTStrCurrentCPToUtf8Tag((ppszString), (pszString), RTSTR_TAG)
     164
     165/**
     166 * Allocates tmp buffer, translates pszString from current codepage to UTF-8.
     167 *
     168 * @returns iprt status code.
     169 * @param   ppszString      Receives pointer of allocated UTF-8 string.
     170 *                          The returned pointer must be freed using RTStrFree().
     171 * @param   pszString       Native string to convert.
     172 * @param   pszTag          Allocation tag used for statistics and such.
     173 */
     174RTR3DECL(int)  RTStrCurrentCPToUtf8Tag(char **ppszString, const char *pszString, const char *pszTag);
     175
     176#endif /* IN_RING3 */
    140177
    141178/**
     
    149186
    150187/**
    151  * Allocates a new copy of the given UTF-8 string.
     188 * Allocates a new copy of the given UTF-8 string (default tag).
    152189 *
    153190 * @returns Pointer to the allocated UTF-8 string.
    154191 * @param   pszString       UTF-8 string to duplicate.
    155192 */
    156 RTDECL(char *) RTStrDup(const char *pszString);
    157 
    158 /**
    159  * Allocates a new copy of the given UTF-8 string.
     193#define RTStrDup(pszString)             RTStrDupTag((pszString), RTSTR_TAG)
     194
     195/**
     196 * Allocates a new copy of the given UTF-8 string (custom tag).
     197 *
     198 * @returns Pointer to the allocated UTF-8 string.
     199 * @param   pszString       UTF-8 string to duplicate.
     200 * @param   pszTag          Allocation tag used for statistics and such.
     201 */
     202RTDECL(char *) RTStrDupTag(const char *pszString, const char *pszTag);
     203
     204/**
     205 * Allocates a new copy of the given UTF-8 string (default tag).
    160206 *
    161207 * @returns iprt status code.
     
    164210 * @param   pszString       UTF-8 string to duplicate.
    165211 */
    166 RTDECL(int)  RTStrDupEx(char **ppszString, const char *pszString);
    167 
    168 /**
    169  * Allocates a new copy of the given UTF-8 substring.
     212#define RTStrDupEx(ppszString, pszString)   RTStrDupExTag((ppszString), (pszString), RTSTR_TAG)
     213
     214/**
     215 * Allocates a new copy of the given UTF-8 string (custom tag).
     216 *
     217 * @returns iprt status code.
     218 * @param   ppszString      Receives pointer of the allocated UTF-8 string.
     219 *                          The returned pointer must be freed using RTStrFree().
     220 * @param   pszString       UTF-8 string to duplicate.
     221 * @param   pszTag          Allocation tag used for statistics and such.
     222 */
     223RTDECL(int)  RTStrDupExTag(char **ppszString, const char *pszString, const char *pszTag);
     224
     225/**
     226 * Allocates a new copy of the given UTF-8 substring (default tag).
    170227 *
    171228 * @returns Pointer to the allocated UTF-8 substring.
     
    174231 *                          the terminator.
    175232 */
    176 RTDECL(char *) RTStrDupN(const char *pszString, size_t cchMax);
    177 
    178 /**
    179  * Appends a string onto an existing IPRT allocated string.
     233#define RTStrDupN(pszString, cchMax)        RTStrDupNTag((pszString), (cchMax), RTSTR_TAG)
     234
     235/**
     236 * Allocates a new copy of the given UTF-8 substring (custom tag).
     237 *
     238 * @returns Pointer to the allocated UTF-8 substring.
     239 * @param   pszString       UTF-8 string to duplicate.
     240 * @param   cchMax          The max number of chars to duplicate, not counting
     241 *                          the terminator.
     242 * @param   pszTag          Allocation tag used for statistics and such.
     243 */
     244RTDECL(char *) RTStrDupNTag(const char *pszString, size_t cchMax, const char *pszTag);
     245
     246/**
     247 * Appends a string onto an existing IPRT allocated string (defaul tag).
    180248 *
    181249 * @retval  VINF_SUCCESS
     
    189257 *                              are quietly ignored.
    190258 */
    191 RTDECL(int) RTStrAAppend(char **ppsz, const char *pszAppend);
    192 
    193 /**
    194  * Appends N bytes from a strings onto an existing IPRT allocated string.
     259#define RTStrAAppend(ppsz, pszAppend)   RTStrAAppendTag((ppsz), (pszAppend), RTSTR_TAG)
     260
     261/**
     262 * Appends a string onto an existing IPRT allocated string (custom tag).
     263 *
     264 * @retval  VINF_SUCCESS
     265 * @retval  VERR_NO_STR_MEMORY if we failed to reallocate the string, @a *ppsz
     266 *          remains unchanged.
     267 *
     268 * @param   ppsz                Pointer to the string pointer.  The string
     269 *                              pointer must either be NULL or point to a string
     270 *                              returned by an IPRT string API.  (In/Out)
     271 * @param   pszAppend           The string to append.  NULL and empty strings
     272 *                              are quietly ignored.
     273 * @param   pszTag              Allocation tag used for statistics and such.
     274 */
     275RTDECL(int) RTStrAAppendTag(char **ppsz, const char *pszAppend, const char *pszTag);
     276
     277/**
     278 * Appends N bytes from a strings onto an existing IPRT allocated string
     279 * (default tag).
    195280 *
    196281 * @retval  VINF_SUCCESS
     
    209294 *                              of @a pszAppend without having to strlen it.
    210295 */
    211 RTDECL(int) RTStrAAppendN(char **ppsz, const char *pszAppend, size_t cchAppend);
     296#define RTStrAAppendN(ppsz, pszAppend, cchAppend)   RTStrAAppendNTag((ppsz), (pszAppend), (cchAppend), RTSTR_TAG)
     297
     298/**
     299 * Appends N bytes from a strings onto an existing IPRT allocated string (custom
     300 * tag).
     301 *
     302 * @retval  VINF_SUCCESS
     303 * @retval  VERR_NO_STR_MEMORY if we failed to reallocate the string, @a *ppsz
     304 *          remains unchanged.
     305 *
     306 * @param   ppsz                Pointer to the string pointer.  The string
     307 *                              pointer must either be NULL or point to a string
     308 *                              returned by an IPRT string API.  (In/Out)
     309 * @param   pszAppend           The string to append.  Can be NULL if cchAppend
     310 *                              is NULL.
     311 * @param   cchAppend           The number of chars (not code points) to append
     312 *                              from pszAppend.   Must not be more than
     313 *                              @a pszAppend contains, except for the special
     314 *                              value RTSTR_MAX that can be used to indicate all
     315 *                              of @a pszAppend without having to strlen it.
     316 * @param   pszTag              Allocation tag used for statistics and such.
     317 */
     318RTDECL(int) RTStrAAppendNTag(char **ppsz, const char *pszAppend, size_t cchAppend, const char *pszTag);
    212319
    213320/**
     
    230337 *                              the string in the first argument.
    231338 */
    232 RTDECL(int) RTStrAAppendExNV(char **ppsz, size_t cPairs, va_list va);
     339#define RTStrAAppendExNV(ppsz, cPairs, va)  RTStrAAppendExNVTag((ppsz), (cPairs), (va), RTSTR_TAG)
    233340
    234341/**
    235342 * Appends one or more strings onto an existing IPRT allocated string.
     343 *
     344 * This is a very flexible and efficient alternative to using RTStrAPrintf to
     345 * combine several strings together.
     346 *
     347 * @retval  VINF_SUCCESS
     348 * @retval  VERR_NO_STR_MEMORY if we failed to reallocate the string, @a *ppsz
     349 *          remains unchanged.
     350 *
     351 * @param   ppsz                Pointer to the string pointer.  The string
     352 *                              pointer must either be NULL or point to a string
     353 *                              returned by an IPRT string API.  (In/Out)
     354 * @param   cPairs              The number of string / length pairs in the
     355 *                              @a va.
     356 * @param   va                  List of string (const char *) and length
     357 *                              (size_t) pairs.  The strings will be appended to
     358 *                              the string in the first argument.
     359 * @param   pszTag              Allocation tag used for statistics and such.
     360 */
     361RTDECL(int) RTStrAAppendExNVTag(char **ppsz, size_t cPairs, va_list va, const char *pszTag);
     362
     363/**
     364 * Appends one or more strings onto an existing IPRT allocated string
     365 * (untagged).
    236366 *
    237367 * This is a very flexible and efficient alternative to using RTStrAPrintf to
     
    251381 *                              the string in the first argument.
    252382 */
    253 RTDECL(int) RTStrAAppendExN(char **ppsz, size_t cPairs, ...);
    254 
    255 /**
    256  * Truncates an IPRT allocated string.
     383DECLINLINE(int) RTStrAAppendExN(char **ppsz, size_t cPairs, ...)
     384{
     385    int     rc;
     386    va_list va;
     387    va_start(va, cPairs);
     388    rc = RTStrAAppendExNVTag(ppsz, cPairs, va, RTSTR_TAG);
     389    va_end(va);
     390    return rc;
     391}
     392
     393/**
     394 * Appends one or more strings onto an existing IPRT allocated string (custom
     395 * tag).
     396 *
     397 * This is a very flexible and efficient alternative to using RTStrAPrintf to
     398 * combine several strings together.
     399 *
     400 * @retval  VINF_SUCCESS
     401 * @retval  VERR_NO_STR_MEMORY if we failed to reallocate the string, @a *ppsz
     402 *          remains unchanged.
     403 *
     404 * @param   ppsz                Pointer to the string pointer.  The string
     405 *                              pointer must either be NULL or point to a string
     406 *                              returned by an IPRT string API.  (In/Out)
     407 * @param   pszTag              Allocation tag used for statistics and such.
     408 * @param   cPairs              The number of string / length pairs in the
     409 *                              ellipsis.
     410 * @param   ...                 List of string (const char *) and length
     411 *                              (size_t) pairs.  The strings will be appended to
     412 *                              the string in the first argument.
     413 */
     414DECLINLINE(int) RTStrAAppendExNTag(char **ppsz, const char *pszTag, size_t cPairs, ...)
     415{
     416    int     rc;
     417    va_list va;
     418    va_start(va, cPairs);
     419    rc = RTStrAAppendExNVTag(ppsz, cPairs, va, pszTag);
     420    va_end(va);
     421    return rc;
     422}
     423
     424/**
     425 * Truncates an IPRT allocated string (default tag).
    257426 *
    258427 * @retval  VINF_SUCCESS.
     
    269438 *                              assert on you.
    270439 */
    271 RTDECL(int) RTStrATruncate(char **ppsz, size_t cchNew);
    272 
    273 /**
    274  * Allocates memory for string storage.
     440#define RTStrATruncate(ppsz, cchNew)    RTStrATruncateTag((ppsz), (cchNew), RTSTR_TAG)
     441
     442/**
     443 * Truncates an IPRT allocated string.
     444 *
     445 * @retval  VINF_SUCCESS.
     446 * @retval  VERR_OUT_OF_RANGE if cchNew is too long.  Nothing is done.
     447 *
     448 * @param   ppsz                Pointer to the string pointer.  The string
     449 *                              pointer can be NULL if @a cchNew is 0, no change
     450 *                              is made then.  If we actually reallocate the
     451 *                              string, the string pointer might be changed by
     452 *                              this call.  (In/Out)
     453 * @param   cchNew              The new string length (excluding the
     454 *                              terminator).  The string must be at least this
     455 *                              long or we'll return VERR_OUT_OF_RANGE and
     456 *                              assert on you.
     457 * @param   pszTag              Allocation tag used for statistics and such.
     458 */
     459RTDECL(int) RTStrATruncateTag(char **ppsz, size_t cchNew, const char *pszTag);
     460
     461/**
     462 * Allocates memory for string storage (default tag).
    275463 *
    276464 * You should normally not use this function, except if there is some very
     
    289477 *                              will allocate a terminator byte anyway.
    290478 */
    291 RTDECL(char *) RTStrAlloc(size_t cb);
    292 
    293 /**
    294  * Allocates memory for string storage, with status code.
     479#define RTStrAlloc(cb)                  RTStrAllocTag((cb), RTSTR_TAG)
     480
     481/**
     482 * Allocates memory for string storage (custom tag).
     483 *
     484 * You should normally not use this function, except if there is some very
     485 * custom string handling you need doing that isn't covered by any of the other
     486 * APIs.
     487 *
     488 * @returns Pointer to the allocated string.  The first byte is always set
     489 *          to the string terminator char, the contents of the remainder of the
     490 *          memory is undefined.  The string must be freed by calling RTStrFree.
     491 *
     492 *          NULL is returned if the allocation failed.  Please translate this to
     493 *          VERR_NO_STR_MEMORY and not VERR_NO_MEMORY.  Also consider
     494 *          RTStrAllocEx if an IPRT status code is required.
     495 *
     496 * @param   cb                  How many bytes to allocate.  If this is zero, we
     497 *                              will allocate a terminator byte anyway.
     498 * @param   pszTag              Allocation tag used for statistics and such.
     499 */
     500RTDECL(char *) RTStrAllocTag(size_t cb, const char *pszTag);
     501
     502/**
     503 * Allocates memory for string storage, with status code (default tag).
    295504 *
    296505 * You should normally not use this function, except if there is some very
     
    310519 *                              will allocate a terminator byte anyway.
    311520 */
    312 RTDECL(int) RTStrAllocEx(char **ppsz, size_t cb);
    313 
    314 /**
    315  * Reallocates the specifed string.
     521#define RTStrAllocEx(ppsz, cb)      RTStrAllocExTag((ppsz), (cb), RTSTR_TAG)
     522
     523/**
     524 * Allocates memory for string storage, with status code (custom tag).
     525 *
     526 * You should normally not use this function, except if there is some very
     527 * custom string handling you need doing that isn't covered by any of the other
     528 * APIs.
     529 *
     530 * @retval  VINF_SUCCESS
     531 * @retval  VERR_NO_STR_MEMORY
     532 *
     533 * @param   ppsz                Where to return the allocated string.  This will
     534 *                              be set to NULL on failure.  On success, the
     535 *                              returned memory will always start with a
     536 *                              terminator char so that it is considered a valid
     537 *                              C string, the contents of rest of the memory is
     538 *                              undefined.
     539 * @param   cb                  How many bytes to allocate.  If this is zero, we
     540 *                              will allocate a terminator byte anyway.
     541 * @param   pszTag              Allocation tag used for statistics and such.
     542 */
     543RTDECL(int) RTStrAllocExTag(char **ppsz, size_t cb, const char *pszTag);
     544
     545/**
     546 * Reallocates the specified string (default tag).
    316547 *
    317548 * You should normally not have use this function, except perhaps to truncate a
     
    344575 *                              terminator char.
    345576 */
    346 RTDECL(int) RTStrRealloc(char **ppsz, size_t cbNew);
     577#define RTStrRealloc(ppsz, cbNew)       RTStrReallocTag((ppsz), (cbNew), RTSTR_TAG)
     578
     579/**
     580 * Reallocates the specified string (custom tag).
     581 *
     582 * You should normally not have use this function, except perhaps to truncate a
     583 * really long string you've got from some IPRT string API, but then you should
     584 * use RTStrATruncate.
     585 *
     586 * @returns VINF_SUCCESS.
     587 * @retval  VERR_NO_STR_MEMORY if we failed to reallocate the string, @a *ppsz
     588 *          remains unchanged.
     589 *
     590 * @param   ppsz                Pointer to the string variable containing the
     591 *                              input and output string.
     592 *
     593 *                              When not freeing the string, the result will
     594 *                              always have the last byte set to the terminator
     595 *                              character so that when used for string
     596 *                              truncation the result will be a valid C string
     597 *                              (your job to keep it a valid UTF-8 string).
     598 *
     599 *                              When the input string is NULL and we're supposed
     600 *                              to reallocate, the returned string will also
     601 *                              have the first byte set to the terminator char
     602 *                              so it will be a valid C string.
     603 *
     604 * @param   cbNew               When @a cbNew is zero, we'll behave like
     605 *                              RTStrFree and @a *ppsz will be set to NULL.
     606 *
     607 *                              When not zero, this will be the new size of the
     608 *                              memory backing the string, i.e. it includes the
     609 *                              terminator char.
     610 * @param   pszTag              Allocation tag used for statistics and such.
     611 */
     612RTDECL(int) RTStrReallocTag(char **ppsz, size_t cbNew, const char *pszTag);
    347613
    348614/**
     
    477743
    478744/**
    479  * Translate a UTF-8 string into a UTF-16 allocating the result buffer.
     745 * Translate a UTF-8 string into a UTF-16 allocating the result buffer (default
     746 * tag).
    480747 *
    481748 * @returns iprt status code.
     
    484751 *                          The returned string must be freed using RTUtf16Free().
    485752 */
    486 RTDECL(int) RTStrToUtf16(const char *pszString, PRTUTF16 *ppwszString);
     753#define RTStrToUtf16(pszString, ppwszString)    RTStrToUtf16Tag((pszString), (ppwszString), RTSTR_TAG)
     754
     755/**
     756 * Translate a UTF-8 string into a UTF-16 allocating the result buffer (custom
     757 * tag).
     758 *
     759 * @returns iprt status code.
     760 * @param   pszString       UTF-8 string to convert.
     761 * @param   ppwszString     Receives pointer to the allocated UTF-16 string.
     762 *                          The returned string must be freed using RTUtf16Free().
     763 * @param   pszTag          Allocation tag used for statistics and such.
     764 */
     765RTDECL(int) RTStrToUtf16Tag(const char *pszString, PRTUTF16 *ppwszString, const char *pszTag);
    487766
    488767/**
     
    508787 *                          length that can be used to resize the buffer.
    509788 */
    510 RTDECL(int)  RTStrToUtf16Ex(const char *pszString, size_t cchString, PRTUTF16 *ppwsz, size_t cwc, size_t *pcwc);
     789#define RTStrToUtf16Ex(pszString, cchString, ppwsz, cwc, pcwc) \
     790    RTStrToUtf16ExTag((pszString), (cchString), (ppwsz), (cwc), (pcwc), RTSTR_TAG)
     791
     792/**
     793 * Translates pszString from UTF-8 to UTF-16, allocating the result buffer if
     794 * requested (custom tag).
     795 *
     796 * @returns iprt status code.
     797 * @param   pszString       UTF-8 string to convert.
     798 * @param   cchString       The maximum size in chars (the type) to convert. The conversion stop
     799 *                          when it reaches cchString or the string terminator ('\\0').
     800 *                          Use RTSTR_MAX to translate the entire string.
     801 * @param   ppwsz           If cwc is non-zero, this must either be pointing to pointer to
     802 *                          a buffer of the specified size, or pointer to a NULL pointer.
     803 *                          If *ppwsz is NULL or cwc is zero a buffer of at least cwc items
     804 *                          will be allocated to hold the translated string.
     805 *                          If a buffer was requested it must be freed using RTUtf16Free().
     806 * @param   cwc             The buffer size in RTUTF16s. This includes the terminator.
     807 * @param   pcwc            Where to store the length of the translated string,
     808 *                          excluding the terminator. (Optional)
     809 *
     810 *                          This may be set under some error conditions,
     811 *                          however, only for VERR_BUFFER_OVERFLOW and
     812 *                          VERR_NO_STR_MEMORY will it contain a valid string
     813 *                          length that can be used to resize the buffer.
     814 * @param   pszTag          Allocation tag used for statistics and such.
     815 */
     816RTDECL(int)  RTStrToUtf16ExTag(const char *pszString, size_t cchString, PRTUTF16 *ppwsz, size_t cwc, size_t *pcwc, const char *pszTag);
    511817
    512818
     
    9481254
    9491255/**
    950  * Allocating string printf.
     1256 * Allocating string printf (default tag).
    9511257 *
    9521258 * @returns The length of the string in the returned *ppszBuffer.
     
    9581264 * @param   args        The format argument.
    9591265 */
    960 RTDECL(int) RTStrAPrintfV(char **ppszBuffer, const char *pszFormat, va_list args);
     1266#define RTStrAPrintfV(ppszBuffer, pszFormat, args)      RTStrAPrintfVTag((ppszBuffer), (pszFormat), (args), RTSTR_TAG)
     1267
     1268/**
     1269 * Allocating string printf (custom tag).
     1270 *
     1271 * @returns The length of the string in the returned *ppszBuffer.
     1272 * @returns -1 on failure.
     1273 * @param   ppszBuffer  Where to store the pointer to the allocated output buffer.
     1274 *                      The buffer should be freed using RTStrFree().
     1275 *                      On failure *ppszBuffer will be set to NULL.
     1276 * @param   pszFormat   The format string.
     1277 * @param   args        The format argument.
     1278 * @param   pszTag      Allocation tag used for statistics and such.
     1279 */
     1280RTDECL(int) RTStrAPrintfVTag(char **ppszBuffer, const char *pszFormat, va_list args, const char *pszTag);
    9611281
    9621282/**
     
    9711291 * @param   ...         The format argument.
    9721292 */
    973 RTDECL(int) RTStrAPrintf(char **ppszBuffer, const char *pszFormat, ...);
     1293DECLINLINE(int) RTStrAPrintf(char **ppszBuffer, const char *pszFormat, ...)
     1294{
     1295    int     cbRet;
     1296    va_list va;
     1297    va_start(va, pszFormat);
     1298    cbRet = RTStrAPrintfVTag(ppszBuffer, pszFormat, va, RTSTR_TAG);
     1299    va_end(va);
     1300    return cbRet;
     1301}
     1302
     1303/**
     1304 * Allocating string printf (custom tag).
     1305 *
     1306 * @returns The length of the string in the returned *ppszBuffer.
     1307 * @returns -1 on failure.
     1308 * @param   ppszBuffer  Where to store the pointer to the allocated output buffer.
     1309 *                      The buffer should be freed using RTStrFree().
     1310 *                      On failure *ppszBuffer will be set to NULL.
     1311 * @param   pszTag      Allocation tag used for statistics and such.
     1312 * @param   pszFormat   The format string.
     1313 * @param   ...         The format argument.
     1314 */
     1315DECLINLINE(int) RTStrAPrintfTag(char **ppszBuffer, const char *pszTag, const char *pszFormat, ...)
     1316{
     1317    int     cbRet;
     1318    va_list va;
     1319    va_start(va, pszFormat);
     1320    cbRet = RTStrAPrintfVTag(ppszBuffer, pszFormat, va, pszTag);
     1321    va_end(va);
     1322    return cbRet;
     1323}
    9741324
    9751325/**
     
    9811331 * @param   args        The format argument.
    9821332 */
    983 RTDECL(char *) RTStrAPrintf2V(const char *pszFormat, va_list args);
    984 
    985 /**
    986  * Allocating string printf, version2.
     1333#define RTStrAPrintf2V(pszFormat, args)     RTStrAPrintf2VTag((pszFormat), (args), RTSTR_TAG)
     1334
     1335/**
     1336 * Allocating string printf, version 2.
     1337 *
     1338 * @returns Formatted string. Use RTStrFree() to free it. NULL when out of
     1339 *          memory.
     1340 * @param   pszFormat   The format string.
     1341 * @param   args        The format argument.
     1342 * @param   pszTag      Allocation tag used for statistics and such.
     1343 */
     1344RTDECL(char *) RTStrAPrintf2VTag(const char *pszFormat, va_list args, const char *pszTag);
     1345
     1346/**
     1347 * Allocating string printf, version 2 (default tag).
    9871348 *
    9881349 * @returns Formatted string. Use RTStrFree() to free it. NULL when out of
     
    9911352 * @param   ...         The format argument.
    9921353 */
    993 RTDECL(char *) RTStrAPrintf2(const char *pszFormat, ...);
     1354DECLINLINE(char *) RTStrAPrintf2(const char *pszFormat, ...)
     1355{
     1356    char   *pszRet;
     1357    va_list va;
     1358    va_start(va, pszFormat);
     1359    pszRet = RTStrAPrintf2VTag(pszFormat, va, RTSTR_TAG);
     1360    va_end(va);
     1361    return pszRet;
     1362}
     1363
     1364/**
     1365 * Allocating string printf, version 2 (custom tag).
     1366 *
     1367 * @returns Formatted string. Use RTStrFree() to free it. NULL when out of
     1368 *          memory.
     1369 * @param   pszTag      Allocation tag used for statistics and such.
     1370 * @param   pszFormat   The format string.
     1371 * @param   ...         The format argument.
     1372 */
     1373DECLINLINE(char *) RTStrAPrintf2Tag(const char *pszTag, const char *pszFormat, ...)
     1374{
     1375    char   *pszRet;
     1376    va_list va;
     1377    va_start(va, pszFormat);
     1378    pszRet = RTStrAPrintf2VTag(pszFormat, va, pszTag);
     1379    va_end(va);
     1380    return pszRet;
     1381}
    9941382
    9951383/**
     
    18872275
    18882276/**
    1889  * Allocates a new copy of the specified UTF-16 string.
     2277 * Allocates a new copy of the specified UTF-16 string (default tag).
    18902278 *
    18912279 * @returns Pointer to the allocated string copy. Use RTUtf16Free() to free it.
     
    18942282 * @remark  This function will not make any attempt to validate the encoding.
    18952283 */
    1896 RTDECL(PRTUTF16) RTUtf16Dup(PCRTUTF16 pwszString);
    1897 
    1898 /**
    1899  * Allocates a new copy of the specified UTF-16 string.
     2284#define RTUtf16Dup(pwszString)          RTUtf16DupTag((pwszString), RTSTR_TAG)
     2285
     2286/**
     2287 * Allocates a new copy of the specified UTF-16 string (custom tag).
     2288 *
     2289 * @returns Pointer to the allocated string copy. Use RTUtf16Free() to free it.
     2290 * @returns NULL when out of memory.
     2291 * @param   pwszString      UTF-16 string to duplicate.
     2292 * @param   pszTag          Allocation tag used for statistics and such.
     2293 * @remark  This function will not make any attempt to validate the encoding.
     2294 */
     2295RTDECL(PRTUTF16) RTUtf16DupTag(PCRTUTF16 pwszString, const char *pszTag);
     2296
     2297/**
     2298 * Allocates a new copy of the specified UTF-16 string (default tag).
    19002299 *
    19012300 * @returns iprt status code.
     
    19062305 * @remark  This function will not make any attempt to validate the encoding.
    19072306 */
    1908 RTDECL(int) RTUtf16DupEx(PRTUTF16 *ppwszString, PCRTUTF16 pwszString, size_t cwcExtra);
     2307#define RTUtf16DupEx(ppwszString, pwszString, cwcExtra) \
     2308    RTUtf16DupExTag((ppwszString), (pwszString), (cwcExtra), RTSTR_TAG)
     2309
     2310/**
     2311 * Allocates a new copy of the specified UTF-16 string (custom tag).
     2312 *
     2313 * @returns iprt status code.
     2314 * @param   ppwszString     Receives pointer of the allocated UTF-16 string.
     2315 *                          The returned pointer must be freed using RTUtf16Free().
     2316 * @param   pwszString      UTF-16 string to duplicate.
     2317 * @param   cwcExtra        Number of extra RTUTF16 items to allocate.
     2318 * @param   pszTag          Allocation tag used for statistics and such.
     2319 * @remark  This function will not make any attempt to validate the encoding.
     2320 */
     2321RTDECL(int) RTUtf16DupExTag(PRTUTF16 *ppwszString, PCRTUTF16 pwszString, size_t cwcExtra, const char *pszTag);
    19092322
    19102323/**
     
    19912404
    19922405/**
    1993  * Translate a UTF-16 string into a UTF-8 allocating the result buffer.
     2406 * Translate a UTF-16 string into a UTF-8 allocating the result buffer (default
     2407 * tag).
    19942408 *
    19952409 * @returns iprt status code.
     
    19992413 *                          The returned pointer must be freed using RTStrFree().
    20002414 */
    2001 RTDECL(int)  RTUtf16ToUtf8(PCRTUTF16 pwszString, char **ppszString);
    2002 
    2003 /**
    2004  * Translates UTF-16 to UTF-8 using buffer provided by the caller or
    2005  * a fittingly sized buffer allocated by the function.
     2415#define RTUtf16ToUtf8(pwszString, ppszString)       RTUtf16ToUtf8Tag((pwszString), (ppszString), RTSTR_TAG)
     2416
     2417/**
     2418 * Translate a UTF-16 string into a UTF-8 allocating the result buffer.
     2419 *
     2420 * @returns iprt status code.
     2421 * @param   pwszString      UTF-16 string to convert.
     2422 * @param   ppszString      Receives pointer of allocated UTF-8 string on
     2423 *                          success, and is always set to NULL on failure.
     2424 *                          The returned pointer must be freed using RTStrFree().
     2425 * @param   pszTag          Allocation tag used for statistics and such.
     2426 */
     2427RTDECL(int)  RTUtf16ToUtf8Tag(PCRTUTF16 pwszString, char **ppszString, const char *pszTag);
     2428
     2429/**
     2430 * Translates UTF-16 to UTF-8 using buffer provided by the caller or a fittingly
     2431 * sized buffer allocated by the function (default tag).
    20062432 *
    20072433 * @returns iprt status code.
     
    20242450 *                          length that can be used to resize the buffer.
    20252451 */
    2026 RTDECL(int)  RTUtf16ToUtf8Ex(PCRTUTF16 pwszString, size_t cwcString, char **ppsz, size_t cch, size_t *pcch);
     2452#define RTUtf16ToUtf8Ex(pwszString, cwcString, ppsz, cch, pcch) \
     2453    RTUtf16ToUtf8ExTag((pwszString), (cwcString), (ppsz), (cch), (pcch), RTSTR_TAG)
     2454
     2455/**
     2456 * Translates UTF-16 to UTF-8 using buffer provided by the caller or a fittingly
     2457 * sized buffer allocated by the function (custom tag).
     2458 *
     2459 * @returns iprt status code.
     2460 * @param   pwszString      The UTF-16 string to convert.
     2461 * @param   cwcString       The number of RTUTF16 items to translate from pwszString.
     2462 *                          The translation will stop when reaching cwcString or the terminator ('\\0').
     2463 *                          Use RTSTR_MAX to translate the entire string.
     2464 * @param   ppsz            If cch is non-zero, this must either be pointing to a pointer to
     2465 *                          a buffer of the specified size, or pointer to a NULL pointer.
     2466 *                          If *ppsz is NULL or cch is zero a buffer of at least cch chars
     2467 *                          will be allocated to hold the translated string.
     2468 *                          If a buffer was requested it must be freed using RTStrFree().
     2469 * @param   cch             The buffer size in chars (the type). This includes the terminator.
     2470 * @param   pcch            Where to store the length of the translated string,
     2471 *                          excluding the terminator. (Optional)
     2472 *
     2473 *                          This may be set under some error conditions,
     2474 *                          however, only for VERR_BUFFER_OVERFLOW and
     2475 *                          VERR_NO_STR_MEMORY will it contain a valid string
     2476 *                          length that can be used to resize the buffer.
     2477 * @param   pszTag          Allocation tag used for statistics and such.
     2478 */
     2479RTDECL(int)  RTUtf16ToUtf8ExTag(PCRTUTF16 pwszString, size_t cwcString, char **ppsz, size_t cch, size_t *pcch, const char *pszTag);
    20272480
    20282481/**
     
    20562509/**
    20572510 * Translate a UTF-16 string into a Latin-1 (ISO-8859-1) allocating the result
    2058  * buffer.
     2511 * buffer (default tag).
    20592512 *
    20602513 * @returns iprt status code.
     
    20642517 *                          The returned pointer must be freed using RTStrFree().
    20652518 */
    2066 RTDECL(int)  RTUtf16ToLatin1(PCRTUTF16 pwszString, char **ppszString);
     2519#define RTUtf16ToLatin1(pwszString, ppszString)     RTUtf16ToLatin1Tag((pwszString), (ppszString), RTSTR_TAG)
     2520
     2521/**
     2522 * Translate a UTF-16 string into a Latin-1 (ISO-8859-1) allocating the result
     2523 * buffer (custom tag).
     2524 *
     2525 * @returns iprt status code.
     2526 * @param   pwszString      UTF-16 string to convert.
     2527 * @param   ppszString      Receives pointer of allocated Latin1 string on
     2528 *                          success, and is always set to NULL on failure.
     2529 *                          The returned pointer must be freed using RTStrFree().
     2530 * @param   pszTag          Allocation tag used for statistics and such.
     2531 */
     2532RTDECL(int)  RTUtf16ToLatin1Tag(PCRTUTF16 pwszString, char **ppszString, const char *pszTag);
    20672533
    20682534/**
    20692535 * Translates UTF-16 to Latin-1 (ISO-8859-1) using buffer provided by the caller
    2070  * or a fittingly sized buffer allocated by the function.
     2536 * or a fittingly sized buffer allocated by the function (default tag).
    20712537 *
    20722538 * @returns iprt status code.
     
    21012567 *                          length that can be used to resize the buffer.
    21022568 */
    2103 RTDECL(int)  RTUtf16ToLatin1Ex(PCRTUTF16 pwszString, size_t cwcString, char **ppsz, size_t cch, size_t *pcch);
     2569#define RTUtf16ToLatin1Ex(pwszString, cwcString, ppsz, cch, pcch) \
     2570    RTUtf16ToLatin1ExTag((pwszString), (cwcString), (ppsz), (cch), (pcch), RTSTR_TAG)
     2571
     2572/**
     2573 * Translates UTF-16 to Latin-1 (ISO-8859-1) using buffer provided by the caller
     2574 * or a fittingly sized buffer allocated by the function (custom tag).
     2575 *
     2576 * @returns iprt status code.
     2577 * @param   pwszString      The UTF-16 string to convert.
     2578 * @param   cwcString       The number of RTUTF16 items to translate from
     2579 *                          pwszString. The translation will stop when reaching
     2580 *                          cwcString or the terminator ('\\0'). Use RTSTR_MAX
     2581 *                          to translate the entire string.
     2582 * @param   ppsz            Pointer to the pointer to the Latin-1 string. The
     2583 *                          buffer can optionally be preallocated by the caller.
     2584 *
     2585 *                          If cch is zero, *ppsz is undefined.
     2586 *
     2587 *                          If cch is non-zero and *ppsz is not NULL, then this
     2588 *                          will be used as the output buffer.
     2589 *                          VERR_BUFFER_OVERFLOW will be returned if this is
     2590 *                          insufficient.
     2591 *
     2592 *                          If cch is zero or *ppsz is NULL, then a buffer of
     2593 *                          sufficent size is allocated. cch can be used to
     2594 *                          specify a minimum size of this buffer. Use
     2595 *                          RTUtf16Free() to free the result.
     2596 *
     2597 * @param   cch             The buffer size in chars (the type). This includes
     2598 *                          the terminator.
     2599 * @param   pcch            Where to store the length of the translated string,
     2600 *                          excluding the terminator. (Optional)
     2601 *
     2602 *                          This may be set under some error conditions,
     2603 *                          however, only for VERR_BUFFER_OVERFLOW and
     2604 *                          VERR_NO_STR_MEMORY will it contain a valid string
     2605 *                          length that can be used to resize the buffer.
     2606 * @param   pszTag          Allocation tag used for statistics and such.
     2607 */
     2608RTDECL(int)  RTUtf16ToLatin1ExTag(PCRTUTF16 pwszString, size_t cwcString, char **ppsz, size_t cch, size_t *pcch, const char *pszTag);
    21042609
    21052610/**
     
    23382843/**
    23392844 * Translate a Latin-1 (ISO-8859-1) string into a UTF-16 allocating the result
    2340  * buffer.
     2845 * buffer (default tag).
    23412846 *
    23422847 * @returns iprt status code.
     
    23452850 *                          returned string must be freed using RTUtf16Free().
    23462851 */
    2347 RTDECL(int) RTLatin1ToUtf16(const char *pszString, PRTUTF16 *ppwszString);
     2852#define RTLatin1ToUtf16(pszString, ppwszString)     RTLatin1ToUtf16Tag((pszString), (ppwszString), RTSTR_TAG)
     2853
     2854/**
     2855 * Translate a Latin-1 (ISO-8859-1) string into a UTF-16 allocating the result
     2856 * buffer (custom tag).
     2857 *
     2858 * @returns iprt status code.
     2859 * @param   pszString       The Latin-1 string to convert.
     2860 * @param   ppwszString     Receives pointer to the allocated UTF-16 string. The
     2861 *                          returned string must be freed using RTUtf16Free().
     2862 * @param   pszTag          Allocation tag used for statistics and such.
     2863 */
     2864RTDECL(int) RTLatin1ToUtf16Tag(const char *pszString, PRTUTF16 *ppwszString, const char *pszTag);
    23482865
    23492866/**
    23502867 * Translates pszString from Latin-1 (ISO-8859-1) to UTF-16, allocating the
    2351  * result buffer if requested.
     2868 * result buffer if requested (default tag).
    23522869 *
    23532870 * @returns iprt status code.
     
    23742891 *                          length that can be used to resize the buffer.
    23752892 */
    2376 RTDECL(int) RTLatin1ToUtf16Ex(const char *pszString, size_t cchString, PRTUTF16 *ppwsz, size_t cwc, size_t *pcwc);
     2893#define RTLatin1ToUtf16Ex(pszString, cchString, ppwsz, cwc, pcwc) \
     2894    RTLatin1ToUtf16ExTag((pszString), (cchString), (ppwsz), (cwc), (pcwc), RTSTR_TAG)
     2895
     2896/**
     2897 * Translates pszString from Latin-1 (ISO-8859-1) to UTF-16, allocating the
     2898 * result buffer if requested.
     2899 *
     2900 * @returns iprt status code.
     2901 * @param   pszString       The Latin-1 string to convert.
     2902 * @param   cchString       The maximum size in chars (the type) to convert.
     2903 *                          The conversion stops when it reaches cchString or
     2904 *                          the string terminator ('\\0').
     2905 *                          Use RTSTR_MAX to translate the entire string.
     2906 * @param   ppwsz           If cwc is non-zero, this must either be pointing
     2907 *                          to pointer to a buffer of the specified size, or
     2908 *                          pointer to a NULL pointer.
     2909 *                          If *ppwsz is NULL or cwc is zero a buffer of at
     2910 *                          least cwc items will be allocated to hold the
     2911 *                          translated string. If a buffer was requested it
     2912 *                          must be freed using RTUtf16Free().
     2913 * @param   cwc             The buffer size in RTUTF16s. This includes the
     2914 *                          terminator.
     2915 * @param   pcwc            Where to store the length of the translated string,
     2916 *                          excluding the terminator. (Optional)
     2917 *
     2918 *                          This may be set under some error conditions,
     2919 *                          however, only for VERR_BUFFER_OVERFLOW and
     2920 *                          VERR_NO_STR_MEMORY will it contain a valid string
     2921 *                          length that can be used to resize the buffer.
     2922 * @param   pszTag          Allocation tag used for statistics and such.
     2923 */
     2924RTDECL(int) RTLatin1ToUtf16ExTag(const char *pszString, size_t cchString,
     2925                                 PRTUTF16 *ppwsz, size_t cwc, size_t *pcwc, const char *pszTag);
    23772926
    23782927/** @} */
  • trunk/src/VBox/HostDrivers/Support/SUPDrv.c

    r30320 r31157  
    55
    66/*
    7  * Copyright (C) 2006-2009 Oracle Corporation
     7 * Copyright (C) 2006-2010 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    181181    { "SUPGetGIP",                              (void *)SUPGetGIP },
    182182    { "g_pSUPGlobalInfoPage",                   (void *)&g_pSUPGlobalInfoPage },
    183     { "RTMemAlloc",                             (void *)RTMemAlloc },
    184     { "RTMemAllocZ",                            (void *)RTMemAllocZ },
     183    { "RTMemAllocTag",                          (void *)RTMemAllocTag },
     184    { "RTMemAllocZTag",                         (void *)RTMemAllocZTag },
     185    { "RTMemAllocVarTag",                       (void *)RTMemAllocVarTag },
     186    { "RTMemAllocZVarTag",                      (void *)RTMemAllocZVarTag },
    185187    { "RTMemFree",                              (void *)RTMemFree },
    186     /*{ "RTMemDup",                               (void *)RTMemDup },
    187     { "RTMemDupEx",                             (void *)RTMemDupEx },*/
    188     { "RTMemRealloc",                           (void *)RTMemRealloc },
    189     { "RTR0MemObjAllocLow",                     (void *)RTR0MemObjAllocLow },
    190     { "RTR0MemObjAllocPage",                    (void *)RTR0MemObjAllocPage },
    191     { "RTR0MemObjAllocPhys",                    (void *)RTR0MemObjAllocPhys },
    192     { "RTR0MemObjAllocPhysEx",                  (void *)RTR0MemObjAllocPhysEx },
    193     { "RTR0MemObjAllocPhysNC",                  (void *)RTR0MemObjAllocPhysNC },
    194     { "RTR0MemObjAllocCont",                    (void *)RTR0MemObjAllocCont },
    195     { "RTR0MemObjEnterPhys",                    (void *)RTR0MemObjEnterPhys },
    196     { "RTR0MemObjLockUser",                     (void *)RTR0MemObjLockUser },
    197     { "RTR0MemObjMapKernel",                    (void *)RTR0MemObjMapKernel },
    198     { "RTR0MemObjMapKernelEx",                  (void *)RTR0MemObjMapKernelEx },
    199     { "RTR0MemObjMapUser",                      (void *)RTR0MemObjMapUser },
     188    { "RTMemDupTag",                            (void *)RTMemDupTag },
     189    { "RTMemDupExTag",                          (void *)RTMemDupExTag },
     190    { "RTMemReallocTag",                        (void *)RTMemReallocTag },
     191    { "RTR0MemObjAllocLowTag",                  (void *)RTR0MemObjAllocLowTag },
     192    { "RTR0MemObjAllocPageTag",                 (void *)RTR0MemObjAllocPageTag },
     193    { "RTR0MemObjAllocPhysTag",                 (void *)RTR0MemObjAllocPhysTag },
     194    { "RTR0MemObjAllocPhysExTag",               (void *)RTR0MemObjAllocPhysExTag },
     195    { "RTR0MemObjAllocPhysNCTag",               (void *)RTR0MemObjAllocPhysNCTag },
     196    { "RTR0MemObjAllocContTag",                 (void *)RTR0MemObjAllocContTag },
     197    { "RTR0MemObjEnterPhysTag",                 (void *)RTR0MemObjEnterPhysTag },
     198    { "RTR0MemObjLockUserTag",                  (void *)RTR0MemObjLockUserTag },
     199    { "RTR0MemObjMapKernelTag",                 (void *)RTR0MemObjMapKernelTag },
     200    { "RTR0MemObjMapKernelExTag",               (void *)RTR0MemObjMapKernelExTag },
     201    { "RTR0MemObjMapUserTag",                   (void *)RTR0MemObjMapUserTag },
    200202    { "RTR0MemObjProtect",                      (void *)RTR0MemObjProtect },
    201203    { "RTR0MemObjAddress",                      (void *)RTR0MemObjAddress },
     
    359361    (PFNRT)RTUuidCompareStr,
    360362    (PFNRT)RTUuidFromStr,
    361     (PFNRT)RTStrDup,
     363    (PFNRT)RTStrDupTag,
    362364    (PFNRT)RTStrFree,
    363365    /* VBoxNetAdp */
     
    12561258                    REQ_CHECK_EXPR_FMT(paSyms[i].offName < pReq->u.In.cbStrTab,
    12571259                                       ("SUP_IOCTL_LDR_LOAD: sym #%ld: name off %#lx (max=%#lx)\n", (long)i, (long)paSyms[i].offName, (long)pReq->u.In.cbImageWithTabs));
    1258                     REQ_CHECK_EXPR_FMT(RTStrEnd(&pReq->u.In.abImage[pReq->u.In.offStrTab + paSyms[i].offName], pReq->u.In.cbStrTab - paSyms[i].offName),
     1260                    REQ_CHECK_EXPR_FMT(RTStrEnd((char const *)&pReq->u.In.abImage[pReq->u.In.offStrTab + paSyms[i].offName],
     1261                                                pReq->u.In.cbStrTab - paSyms[i].offName),
    12591262                                       ("SUP_IOCTL_LDR_LOAD: sym #%ld: unterminated name! (%#lx / %#lx)\n", (long)i, (long)paSyms[i].offName, (long)pReq->u.In.cbImageWithTabs));
    12601263                }
  • trunk/src/VBox/HostDrivers/Support/SUPDrvIOC.h

    r28800 r31157  
    55
    66/*
    7  * Copyright (C) 2006-2007 Oracle Corporation
     7 * Copyright (C) 2006-2010 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    193193 *          - Nothing.
    194194 */
    195 #define SUPDRV_IOC_VERSION                              0x00140001
     195#define SUPDRV_IOC_VERSION                              0x00150000
    196196
    197197/** SUP_IOCTL_COOKIE. */
  • trunk/src/VBox/HostDrivers/Support/SUPLib.cpp

    r30112 r31157  
    55
    66/*
    7  * Copyright (C) 2006-2007 Oracle Corporation
     7 * Copyright (C) 2006-2010 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    268268        strcpy(CookieReq.u.In.szMagic, SUPCOOKIE_MAGIC);
    269269        CookieReq.u.In.u32ReqVersion = SUPDRV_IOC_VERSION;
    270         const uint32_t uMinVersion = (SUPDRV_IOC_VERSION & 0xffff0000) == 0x00140000
    271                                    ?  0x00140001
    272                                    :  SUPDRV_IOC_VERSION & 0xffff0000;
     270        const uint32_t uMinVersion = /*(SUPDRV_IOC_VERSION & 0xffff0000) == 0x00150000
     271                                   ?  0x00150001
     272                                   :*/ SUPDRV_IOC_VERSION & 0xffff0000;
    273273        CookieReq.u.In.u32MinVersion = uMinVersion;
    274274        rc = suplibOsIOCtl(&g_supLibData, SUP_IOCTL_COOKIE, &CookieReq, SUP_IOCTL_COOKIE_SIZE);
  • trunk/src/VBox/Runtime/common/alloc/alloc.cpp

    r28800 r31157  
    55
    66/*
    7  * Copyright (C) 2006-2007 Oracle Corporation
     7 * Copyright (C) 2006-2010 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3636
    3737#undef RTMemDup
     38#undef RTMemDupTag
    3839#undef RTMemDupEx
     40#undef RTMemDupExTag
    3941
    4042
    4143
    42 /**
    43  * Duplicates a chunk of memory into a new heap block.
    44  *
    45  * @returns New heap block with the duplicate data.
    46  * @returns NULL if we're out of memory.
    47  * @param   pvSrc   The memory to duplicate.
    48  * @param   cb      The amount of memory to duplicate.
    49  */
    50 RTDECL(void *) RTMemDup(const void *pvSrc, size_t cb) RT_NO_THROW
     44RTDECL(void *) RTMemDupTag(const void *pvSrc, size_t cb, const char *pszTag) RT_NO_THROW
    5145{
    52     void *pvDst = RTMemAlloc(cb);
     46    void *pvDst = RTMemAllocTag(cb, pszTag);
    5347    if (pvDst)
    5448        memcpy(pvDst, pvSrc, cb);
    5549    return pvDst;
    5650}
    57 RT_EXPORT_SYMBOL(RTMemDup);
     51RT_EXPORT_SYMBOL(RTMemDupTag);
    5852
    5953
    60 /**
    61  * Duplicates a chunk of memory into a new heap block with some
    62  * additional zeroed memory.
    63  *
    64  * @returns New heap block with the duplicate data.
    65  * @returns NULL if we're out of memory.
    66  * @param   pvSrc   The memory to duplicate.
    67  * @param   cbSrc   The amount of memory to duplicate.
    68  * @param   cbExtra The amount of extra memory to allocate and zero.
    69  */
    70 RTDECL(void *) RTMemDupEx(const void *pvSrc, size_t cbSrc, size_t cbExtra) RT_NO_THROW
     54RTDECL(void *) RTMemDupExTag(const void *pvSrc, size_t cbSrc, size_t cbExtra, const char *pszTag) RT_NO_THROW
    7155{
    72     void *pvDst = RTMemAlloc(cbSrc + cbExtra);
     56    void *pvDst = RTMemAllocTag(cbSrc + cbExtra, pszTag);
    7357    if (pvDst)
    7458    {
     
    7862    return pvDst;
    7963}
    80 RT_EXPORT_SYMBOL(RTMemDupEx);
     64RT_EXPORT_SYMBOL(RTMemDupExTag);
    8165
  • trunk/src/VBox/Runtime/common/string/straprintf.cpp

    r28800 r31157  
    55
    66/*
    7  * Copyright (C) 2006-2007 Oracle Corporation
     7 * Copyright (C) 2006-2010 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    4343{
    4444    /** Pointer to current buffer position. */
    45     char   *psz;
     45    char       *psz;
    4646    /** Number of bytes left in the buffer - not including the trailing zero. */
    47     size_t  cch;
     47    size_t      cch;
    4848    /** Pointer to the start of the buffer. */
    49     char   *pszBuffer;
     49    char       *pszBuffer;
    5050    /** The number of bytes in the buffer. */
    51     size_t  cchBuffer;
     51    size_t      cchBuffer;
    5252    /** Set if the buffer was allocated using RTMemRealloc(). If clear
    5353     * pszBuffer points to the initial stack buffer. */
    54     bool    fAllocated;
     54    bool        fAllocated;
     55    /** Allocation tag used for statistics and such. */
     56    const char *pszTag;
    5557} STRALLOCARG;
    5658/** Pointer to a strallocoutput() argument structure. */
     
    100102        if (cbAdded <= _1G)
    101103        {
    102             char *pszBuffer = (char *)RTMemRealloc(pArg->fAllocated ? pArg->pszBuffer : NULL, cbAdded + pArg->cchBuffer);
     104            char *pszBuffer = (char *)RTMemReallocTag(pArg->fAllocated ? pArg->pszBuffer : NULL,
     105                                                      cbAdded + pArg->cchBuffer, pArg->pszTag);
    103106            if (pszBuffer)
    104107            {
     
    135138
    136139
    137 RTDECL(int) RTStrAPrintfV(char **ppszBuffer, const char *pszFormat, va_list args)
     140RTDECL(int) RTStrAPrintfVTag(char **ppszBuffer, const char *pszFormat, va_list args, const char *pszTag)
    138141{
    139142    char            szBuf[2048];
     
    144147    Arg.cch         = sizeof(szBuf) - 1;
    145148    Arg.psz         = szBuf;
     149    Arg.pszTag      = pszTag;
    146150    szBuf[0] = '\0';
    147151    int cbRet = (int)RTStrFormatV(strallocoutput, &Arg, NULL, NULL, pszFormat, args);
     
    152156            /* duplicate the string in szBuf */
    153157            Assert(Arg.pszBuffer == szBuf);
    154             char *psz = (char *)RTMemAlloc(cbRet + 1);
     158            char *psz = (char *)RTMemAllocTag(cbRet + 1, pszTag);
    155159            if (psz)
    156160                memcpy(psz, szBuf, cbRet + 1);
     
    160164        {
    161165            /* adjust the allocated buffer */
    162             char *psz = (char *)RTMemRealloc(Arg.pszBuffer, cbRet + 1);
     166            char *psz = (char *)RTMemReallocTag(Arg.pszBuffer, cbRet + 1, pszTag);
    163167            *ppszBuffer = psz ? psz : Arg.pszBuffer;
    164168        }
     
    177181    return cbRet;
    178182}
    179 RT_EXPORT_SYMBOL(RTStrAPrintfV);
     183RT_EXPORT_SYMBOL(RTStrAPrintfVTag);
    180184
    181185
    182 RTDECL(int) RTStrAPrintf(char **ppszBuffer, const char *pszFormat, ...)
    183 {
    184     va_list args;
    185     va_start(args, pszFormat);
    186     int cbRet = RTStrAPrintfV(ppszBuffer, pszFormat, args);
    187     va_end(args);
    188     return cbRet;
    189 }
    190 RT_EXPORT_SYMBOL(RTStrAPrintf);
    191 
    192 
    193 RTDECL(char *) RTStrAPrintf2V(const char *pszFormat, va_list args)
     186RTDECL(char *) RTStrAPrintf2VTag(const char *pszFormat, va_list args, const char *pszTag)
    194187{
    195188    char *pszBuffer;
    196     RTStrAPrintfV(&pszBuffer, pszFormat, args);
     189    RTStrAPrintfVTag(&pszBuffer, pszFormat, args, pszTag);
    197190    return pszBuffer;
    198191}
    199 RT_EXPORT_SYMBOL(RTStrAPrintf2V);
     192RT_EXPORT_SYMBOL(RTStrAPrintf2VTag);
    200193
    201 
    202 RTDECL(char *) RTStrAPrintf2(const char *pszFormat, ...)
    203 {
    204     va_list va;
    205     char   *pszBuffer;
    206 
    207     va_start(va, pszFormat);
    208     RTStrAPrintfV(&pszBuffer, pszFormat, va);
    209     va_end(va);
    210 
    211     return pszBuffer;
    212 }
    213 RT_EXPORT_SYMBOL(RTStrAPrintf2);
    214 
  • trunk/src/VBox/Runtime/common/string/stringalloc.cpp

    r30320 r31157  
    55
    66/*
    7  * Copyright (C) 2006-2007 Oracle Corporation
     7 * Copyright (C) 2006-2010 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    4040
    4141
    42 RTDECL(char *) RTStrAlloc(size_t cb)
    43 {
    44     char *psz = (char *)RTMemAlloc(RT_MAX(cb, 1));
     42RTDECL(char *) RTStrAllocTag(size_t cb, const char *pszTag)
     43{
     44    char *psz = (char *)RTMemAllocTag(RT_MAX(cb, 1), pszTag);
    4545    if (psz)
    4646        *psz = '\0';
    4747    return psz;
    4848}
    49 RT_EXPORT_SYMBOL(RTStrAlloc);
    50 
    51 
    52 RTDECL(int) RTStrAllocEx(char **ppsz, size_t cb)
    53 {
    54     char *psz = *ppsz = (char *)RTMemAlloc(RT_MAX(cb, 1));
     49RT_EXPORT_SYMBOL(RTStrAllocTag);
     50
     51
     52RTDECL(int) RTStrAllocExTag(char **ppsz, size_t cb, const char *pszTag)
     53{
     54    char *psz = *ppsz = (char *)RTMemAllocTag(RT_MAX(cb, 1), pszTag);
    5555    if (psz)
    5656    {
     
    6060    return VERR_NO_STR_MEMORY;
    6161}
    62 RT_EXPORT_SYMBOL(RTStrAlloc);
    63 
    64 
    65 RTDECL(int) RTStrRealloc(char **ppsz, size_t cbNew)
     62RT_EXPORT_SYMBOL(RTStrAllocTag);
     63
     64
     65RTDECL(int) RTStrReallocTag(char **ppsz, size_t cbNew, const char *pszTag)
    6666{
    6767    char *pszOld = *ppsz;
     
    7373    else if (pszOld)
    7474    {
    75         char *pszNew = (char *)RTMemRealloc(pszOld, cbNew);
     75        char *pszNew = (char *)RTMemReallocTag(pszOld, cbNew, pszTag);
    7676        if (!pszNew)
    7777            return VERR_NO_STR_MEMORY;
     
    8181    else
    8282    {
    83         char *pszNew = (char *)RTMemAlloc(cbNew);
     83        char *pszNew = (char *)RTMemAllocTag(cbNew, pszTag);
    8484        if (!pszNew)
    8585            return VERR_NO_STR_MEMORY;
     
    9090    return VINF_SUCCESS;
    9191}
     92RT_EXPORT_SYMBOL(RTStrReallocTag);
    9293
    9394RTDECL(void)  RTStrFree(char *pszString)
     
    99100
    100101
    101 RTDECL(char *) RTStrDup(const char *pszString)
     102RTDECL(char *) RTStrDupTag(const char *pszString, const char *pszTag)
    102103{
    103104    AssertPtr(pszString);
    104105    size_t cch = strlen(pszString) + 1;
    105     char *psz = (char *)RTMemAlloc(cch);
     106    char *psz = (char *)RTMemAllocTag(cch, pszTag);
    106107    if (psz)
    107108        memcpy(psz, pszString, cch);
    108109    return psz;
    109110}
    110 RT_EXPORT_SYMBOL(RTStrDup);
    111 
    112 
    113 RTDECL(int)  RTStrDupEx(char **ppszString, const char *pszString)
     111RT_EXPORT_SYMBOL(RTStrDupTag);
     112
     113
     114RTDECL(int)  RTStrDupExTag(char **ppszString, const char *pszString, const char *pszTag)
    114115{
    115116    AssertPtr(ppszString);
     
    117118
    118119    size_t cch = strlen(pszString) + 1;
    119     char *psz = (char *)RTMemAlloc(cch);
     120    char *psz = (char *)RTMemAllocTag(cch, pszTag);
    120121    if (psz)
    121122    {
     
    126127    return VERR_NO_MEMORY;
    127128}
    128 RT_EXPORT_SYMBOL(RTStrDupEx);
    129 
    130 
    131 RTDECL(char *) RTStrDupN(const char *pszString, size_t cchMax)
     129RT_EXPORT_SYMBOL(RTStrDupExTag);
     130
     131
     132RTDECL(char *) RTStrDupNTag(const char *pszString, size_t cchMax, const char *pszTag)
    132133{
    133134    AssertPtr(pszString);
    134135    char const *pszEnd = RTStrEnd(pszString, cchMax);
    135136    size_t      cch    = pszEnd ? (uintptr_t)pszEnd - (uintptr_t)pszString : cchMax;
    136     char       *pszDst = (char *)RTMemAlloc(cch + 1);
     137    char       *pszDst = (char *)RTMemAllocTag(cch + 1, pszTag);
    137138    if (pszDst)
    138139    {
     
    142143    return pszDst;
    143144}
    144 RT_EXPORT_SYMBOL(RTStrDupN);
    145 
    146 
    147 RTDECL(int) RTStrAAppend(char **ppsz, const char *pszAppend)
     145RT_EXPORT_SYMBOL(RTStrDupNTag);
     146
     147
     148RTDECL(int) RTStrAAppendTag(char **ppsz, const char *pszAppend, const char *pszTag)
    148149{
    149150    if (!pszAppend)
    150151        return VINF_SUCCESS;
    151     return RTStrAAppendN(ppsz, pszAppend, RTSTR_MAX);
    152 }
    153 
    154 
    155 RTDECL(int) RTStrAAppendN(char **ppsz, const char *pszAppend, size_t cchAppend)
     152    return RTStrAAppendNTag(ppsz, pszAppend, RTSTR_MAX, pszTag);
     153}
     154
     155
     156RTDECL(int) RTStrAAppendNTag(char **ppsz, const char *pszAppend, size_t cchAppend, const char *pszTag)
    156157{
    157158    if (!cchAppend)
     
    163164
    164165    size_t const cchOrg = *ppsz ? strlen(*ppsz) : 0;
    165     char *pszNew = (char *)RTMemRealloc(*ppsz, cchOrg + cchAppend + 1);
     166    char *pszNew = (char *)RTMemReallocTag(*ppsz, cchOrg + cchAppend + 1, pszTag);
    166167    if (!pszNew)
    167168        return VERR_NO_STR_MEMORY;
     
    175176
    176177
    177 RTDECL(int) RTStrAAppendExNV(char **ppsz, size_t cPairs, va_list va)
     178RTDECL(int) RTStrAAppendExNVTag(char **ppsz, size_t cPairs, va_list va, const char *pszTag)
    178179{
    179180    AssertPtr(ppsz);
     
    212213     * Try reallocate the string.
    213214     */
    214     char *pszNew = (char *)RTMemRealloc(*ppsz, cchNewTotal);
     215    char *pszNew = (char *)RTMemReallocTag(*ppsz, cchNewTotal, pszTag);
    215216    if (!pszNew)
    216217        return VERR_NO_STR_MEMORY;
     
    232233    return VINF_SUCCESS;
    233234}
    234 RT_EXPORT_SYMBOL(RTStrAAppendExNV);
    235 
    236 
    237 RTDECL(int) RTStrAAppendExN(char **ppsz, size_t cPairs, ...)
    238 {
    239     va_list va;
    240     va_start(va, cPairs);
    241     int rc = RTStrAAppendExNV(ppsz, cPairs, va);
    242     va_end(va);
    243     return rc;
    244 }
    245 RT_EXPORT_SYMBOL(RTStrAAppendExN);
    246 
    247 
    248 RTDECL(int) RTStrATruncate(char **ppsz, size_t cchNew)
     235RT_EXPORT_SYMBOL(RTStrAAppendExNVTag);
     236
     237
     238RTDECL(int) RTStrATruncateTag(char **ppsz, size_t cchNew, const char *pszTag)
    249239{
    250240    char *pszOld = *ppsz;
     
    254244        {
    255245            *pszOld = '\0';
    256             char *pszNew = (char *)RTMemRealloc(pszOld, 1);
     246            char *pszNew = (char *)RTMemReallocTag(pszOld, 1, pszTag);
    257247            if (pszNew)
    258248                *ppsz = pszNew;
     
    268258        if (!pszZero)
    269259        {
    270             char *pszNew = (char *)RTMemRealloc(pszOld,  cchNew + 1);
     260            char *pszNew = (char *)RTMemReallocTag(pszOld,  cchNew + 1, pszTag);
    271261            if (pszNew)
    272262                *ppsz = pszNew;
     
    275265    return VINF_SUCCESS;
    276266}
    277 RT_EXPORT_SYMBOL(RTStrATruncate);
    278 
     267RT_EXPORT_SYMBOL(RTStrATruncateTag);
     268
  • trunk/src/VBox/Runtime/common/string/utf-16.cpp

    r30749 r31157  
    55
    66/*
    7  * Copyright (C) 2006-2007 Oracle Corporation
     7 * Copyright (C) 2006-2010 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    4848
    4949
    50 RTDECL(PRTUTF16) RTUtf16Dup(PCRTUTF16 pwszString)
     50RTDECL(PRTUTF16) RTUtf16DupTag(PCRTUTF16 pwszString, const char *pszTag)
    5151{
    5252    Assert(pwszString);
    5353    size_t cb = (RTUtf16Len(pwszString) + 1) * sizeof(RTUTF16);
    54     PRTUTF16 pwsz = (PRTUTF16)RTMemAlloc(cb);
     54    PRTUTF16 pwsz = (PRTUTF16)RTMemAllocTag(cb, pszTag);
    5555    if (pwsz)
    5656        memcpy(pwsz, pwszString, cb);
    5757    return pwsz;
    5858}
    59 RT_EXPORT_SYMBOL(RTUtf16Dup);
    60 
    61 
    62 RTDECL(int) RTUtf16DupEx(PRTUTF16 *ppwszString, PCRTUTF16 pwszString, size_t cwcExtra)
     59RT_EXPORT_SYMBOL(RTUtf16DupTag);
     60
     61
     62RTDECL(int) RTUtf16DupExTag(PRTUTF16 *ppwszString, PCRTUTF16 pwszString, size_t cwcExtra, const char *pszTag)
    6363{
    6464    Assert(pwszString);
    6565    size_t cb = (RTUtf16Len(pwszString) + 1) * sizeof(RTUTF16);
    66     PRTUTF16 pwsz = (PRTUTF16)RTMemAlloc(cb + cwcExtra * sizeof(RTUTF16));
     66    PRTUTF16 pwsz = (PRTUTF16)RTMemAllocTag(cb + cwcExtra * sizeof(RTUTF16), pszTag);
    6767    if (pwsz)
    6868    {
     
    7373    return VERR_NO_MEMORY;
    7474}
    75 RT_EXPORT_SYMBOL(RTUtf16DupEx);
     75RT_EXPORT_SYMBOL(RTUtf16DupExTag);
    7676
    7777
     
    425425
    426426
    427 RTDECL(int)  RTUtf16ToUtf8(PCRTUTF16 pwszString, char **ppszString)
     427RTDECL(int)  RTUtf16ToUtf8Tag(PCRTUTF16 pwszString, char **ppszString, const char *pszTag)
    428428{
    429429    /*
     
    444444         * Allocate buffer and recode it.
    445445         */
    446         char *pszResult = (char *)RTMemAlloc(cch + 1);
     446        char *pszResult = (char *)RTMemAllocTag(cch + 1, pszTag);
    447447        if (pszResult)
    448448        {
     
    461461    return rc;
    462462}
    463 RT_EXPORT_SYMBOL(RTUtf16ToUtf8);
    464 
    465 
    466 RTDECL(int)  RTUtf16ToUtf8Ex(PCRTUTF16 pwszString, size_t cwcString, char **ppsz, size_t cch, size_t *pcch)
     463RT_EXPORT_SYMBOL(RTUtf16ToUtf8Tag);
     464
     465
     466RTDECL(int)  RTUtf16ToUtf8ExTag(PCRTUTF16 pwszString, size_t cwcString, char **ppsz, size_t cch, size_t *pcch, const char *pszTag)
    467467{
    468468    /*
     
    500500            fShouldFree = true;
    501501            cch = RT_MAX(cch, cchResult + 1);
    502             pszResult = (char *)RTStrAlloc(cch);
     502            pszResult = (char *)RTStrAllocTag(cch, pszTag);
    503503        }
    504504        if (pszResult)
     
    519519    return rc;
    520520}
    521 RT_EXPORT_SYMBOL(RTUtf16ToUtf8Ex);
     521RT_EXPORT_SYMBOL(RTUtf16ToUtf8ExTag);
    522522
    523523
     
    785785
    786786
    787 RTDECL(int)  RTUtf16ToLatin1(PCRTUTF16 pwszString, char **ppszString)
     787RTDECL(int)  RTUtf16ToLatin1Tag(PCRTUTF16 pwszString, char **ppszString, const char *pszTag)
    788788{
    789789    /*
     
    804804         * Allocate buffer and recode it.
    805805         */
    806         char *pszResult = (char *)RTMemAlloc(cch + 1);
     806        char *pszResult = (char *)RTMemAllocTag(cch + 1, pszTag);
    807807        if (pszResult)
    808808        {
     
    821821    return rc;
    822822}
    823 RT_EXPORT_SYMBOL(RTUtf16ToLatin1);
    824 
    825 
    826 RTDECL(int)  RTUtf16ToLatin1Ex(PCRTUTF16 pwszString, size_t cwcString, char **ppsz, size_t cch, size_t *pcch)
     823RT_EXPORT_SYMBOL(RTUtf16ToLatin1Tag);
     824
     825
     826RTDECL(int)  RTUtf16ToLatin1ExTag(PCRTUTF16 pwszString, size_t cwcString, char **ppsz, size_t cch, size_t *pcch, const char *pszTag)
    827827{
    828828    /*
     
    860860            fShouldFree = true;
    861861            cch = RT_MAX(cch, cchResult + 1);
    862             pszResult = (char *)RTMemAlloc(cch);
     862            pszResult = (char *)RTMemAllocTag(cch, pszTag);
    863863        }
    864864        if (pszResult)
     
    879879    return rc;
    880880}
    881 RT_EXPORT_SYMBOL(RTUtf16ToLatin1Ex);
     881RT_EXPORT_SYMBOL(RTUtf16ToLatin1ExTag);
    882882
    883883
     
    964964
    965965
    966 RTDECL(int) RTLatin1ToUtf16(const char *pszString, PRTUTF16 *ppwszString)
     966RTDECL(int) RTLatin1ToUtf16Tag(const char *pszString, PRTUTF16 *ppwszString, const char *pszTag)
    967967{
    968968    /*
     
    983983         * Allocate buffer.
    984984         */
    985         PRTUTF16 pwsz = (PRTUTF16)RTMemAlloc((cwc + 1) * sizeof(RTUTF16));
     985        PRTUTF16 pwsz = (PRTUTF16)RTMemAllocTag((cwc + 1) * sizeof(RTUTF16), pszTag);
    986986        if (pwsz)
    987987        {
     
    10021002    return rc;
    10031003}
    1004 RT_EXPORT_SYMBOL(RTLatin1ToUtf16);
    1005 
    1006 
    1007 RTDECL(int)  RTLatin1ToUtf16Ex(const char *pszString, size_t cchString, PRTUTF16 *ppwsz, size_t cwc, size_t *pcwc)
     1004RT_EXPORT_SYMBOL(RTLatin1ToUtf16Tag);
     1005
     1006
     1007RTDECL(int)  RTLatin1ToUtf16ExTag(const char *pszString, size_t cchString,
     1008                                  PRTUTF16 *ppwsz, size_t cwc, size_t *pcwc, const char *pszTag)
    10081009{
    10091010    /*
     
    10411042            fShouldFree = true;
    10421043            cwc = RT_MAX(cwcResult + 1, cwc);
    1043             pwszResult = (PRTUTF16)RTMemAlloc(cwc * sizeof(RTUTF16));
     1044            pwszResult = (PRTUTF16)RTMemAllocTag(cwc * sizeof(RTUTF16), pszTag);
    10441045        }
    10451046        if (pwszResult)
     
    10621063    return rc;
    10631064}
    1064 RT_EXPORT_SYMBOL(RTLatin1ToUtf16Ex);
     1065RT_EXPORT_SYMBOL(RTLatin1ToUtf16ExTag);
    10651066
    10661067
  • trunk/src/VBox/Runtime/common/string/utf-8.cpp

    r30859 r31157  
    55
    66/*
    7  * Copyright (C) 2006-2009 Oracle Corporation
     7 * Copyright (C) 2006-2010 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    672672
    673673
    674 RTDECL(int) RTStrToUtf16(const char *pszString, PRTUTF16 *ppwszString)
     674RTDECL(int) RTStrToUtf16Tag(const char *pszString, PRTUTF16 *ppwszString, const char *pszTag)
    675675{
    676676    /*
     
    691691         * Allocate buffer.
    692692         */
    693         PRTUTF16 pwsz = (PRTUTF16)RTMemAlloc((cwc + 1) * sizeof(RTUTF16));
     693        PRTUTF16 pwsz = (PRTUTF16)RTMemAllocTag((cwc + 1) * sizeof(RTUTF16), pszTag);
    694694        if (pwsz)
    695695        {
     
    710710    return rc;
    711711}
    712 RT_EXPORT_SYMBOL(RTStrToUtf16);
    713 
    714 
    715 RTDECL(int)  RTStrToUtf16Ex(const char *pszString, size_t cchString, PRTUTF16 *ppwsz, size_t cwc, size_t *pcwc)
     712RT_EXPORT_SYMBOL(RTStrToUtf16Tag);
     713
     714
     715RTDECL(int)  RTStrToUtf16ExTag(const char *pszString, size_t cchString,
     716                               PRTUTF16 *ppwsz, size_t cwc, size_t *pcwc, const char *pszTag)
    716717{
    717718    /*
     
    749750            fShouldFree = true;
    750751            cwc = RT_MAX(cwcResult + 1, cwc);
    751             pwszResult = (PRTUTF16)RTMemAlloc(cwc * sizeof(RTUTF16));
     752            pwszResult = (PRTUTF16)RTMemAllocTag(cwc * sizeof(RTUTF16), pszTag);
    752753        }
    753754        if (pwszResult)
     
    770771    return rc;
    771772}
    772 RT_EXPORT_SYMBOL(RTStrToUtf16Ex);
     773RT_EXPORT_SYMBOL(RTStrToUtf16ExTag);
    773774
    774775
  • trunk/src/VBox/Runtime/r0drv/alloc-r0drv.cpp

    r29250 r31157  
    55
    66/*
    7  * Copyright (C) 2006-2007 Oracle Corporation
     7 * Copyright (C) 2006-2010 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    8181
    8282
    83 
    84 /**
    85  * Allocates temporary memory.
    86  *
    87  * Temporary memory blocks are used for not too large memory blocks which
    88  * are believed not to stick around for too long. Using this API instead
    89  * of RTMemAlloc() not only gives the heap manager room for optimization
    90  * but makes the code easier to read.
    91  *
    92  * @returns Pointer to the allocated memory.
    93  * @returns NULL on failure.
    94  * @param   cb      Size in bytes of the memory block to allocated.
    95  */
    96 RTDECL(void *)  RTMemTmpAlloc(size_t cb) RT_NO_THROW
    97 {
    98     return RTMemAlloc(cb);
    99 }
    100 RT_EXPORT_SYMBOL(RTMemTmpAlloc);
    101 
    102 
    103 /**
    104  * Allocates zero'ed temporary memory.
    105  *
    106  * Same as RTMemTmpAlloc() but the memory will be zero'ed.
    107  *
    108  * @returns Pointer to the allocated memory.
    109  * @returns NULL on failure.
    110  * @param   cb      Size in bytes of the memory block to allocated.
    111  */
    112 RTDECL(void *)  RTMemTmpAllocZ(size_t cb) RT_NO_THROW
    113 {
    114     return RTMemAllocZ(cb);
    115 }
    116 RT_EXPORT_SYMBOL(RTMemTmpAllocZ);
    117 
    118 
    119 /**
    120  * Free temporary memory.
    121  *
    122  * @param   pv      Pointer to memory block.
    123  */
     83#undef RTMemTmpAlloc
     84#undef RTMemTmpAllocTag
     85#undef RTMemTmpAllocZ
     86#undef RTMemTmpAllocZTag
     87#undef RTMemTmpFree
     88#undef RTMemAlloc
     89#undef RTMemAllocTag
     90#undef RTMemAllocZ
     91#undef RTMemAllocZTag
     92#undef RTMemAllocVar
     93#undef RTMemAllocVarTag
     94#undef RTMemAllocZVar
     95#undef RTMemAllocZVarTag
     96#undef RTMemRealloc
     97#undef RTMemReallocTag
     98#undef RTMemFree
     99#undef RTMemDup
     100#undef RTMemDupTag
     101#undef RTMemDupEx
     102#undef RTMemDupExTag
     103
     104
     105
     106RTDECL(void *)  RTMemTmpAllocTag(size_t cb, const char *pszTag) RT_NO_THROW
     107{
     108    return RTMemAllocTag(cb, pszTag);
     109}
     110RT_EXPORT_SYMBOL(RTMemTmpAllocTag);
     111
     112
     113RTDECL(void *)  RTMemTmpAllocZTag(size_t cb, const char *pszTag) RT_NO_THROW
     114{
     115    return RTMemAllocZTag(cb, pszTag);
     116}
     117RT_EXPORT_SYMBOL(RTMemTmpAllocZTag);
     118
     119
    124120RTDECL(void)    RTMemTmpFree(void *pv) RT_NO_THROW
    125121{
     
    129125
    130126
    131 /**
    132  * Allocates memory.
    133  *
    134  * @returns Pointer to the allocated memory.
    135  * @returns NULL on failure.
    136  * @param   cb      Size in bytes of the memory block to allocated.
    137  */
    138 RTDECL(void *)  RTMemAlloc(size_t cb) RT_NO_THROW
     127
     128
     129
     130RTDECL(void *)  RTMemAllocTag(size_t cb, const char *pszTag) RT_NO_THROW
    139131{
    140132    PRTMEMHDR pHdr;
     
    152144    return NULL;
    153145}
    154 RT_EXPORT_SYMBOL(RTMemAlloc);
    155 
    156 
    157 /**
    158  * Allocates zero'ed memory.
    159  *
    160  * Instead of memset(pv, 0, sizeof()) use this when you want zero'ed
    161  * memory. This keeps the code smaller and the heap can skip the memset
    162  * in about 0.42% of calls :-).
    163  *
    164  * @returns Pointer to the allocated memory.
    165  * @returns NULL on failure.
    166  * @param   cb      Size in bytes of the memory block to allocated.
    167  */
    168 RTDECL(void *)  RTMemAllocZ(size_t cb) RT_NO_THROW
     146RT_EXPORT_SYMBOL(RTMemAllocTag);
     147
     148
     149RTDECL(void *)  RTMemAllocZTag(size_t cb, const char *pszTag) RT_NO_THROW
    169150{
    170151    PRTMEMHDR pHdr;
     
    184165    return NULL;
    185166}
    186 RT_EXPORT_SYMBOL(RTMemAllocZ);
    187 
    188 
    189 /**
    190  * Wrapper around RTMemAlloc for automatically aligning variable sized
    191  * allocations so that the various electric fence heaps works correctly.
    192  *
    193  * @returns See RTMemAlloc.
    194  * @param   cbUnaligned         The unaligned size.
    195  */
    196 RTDECL(void *) RTMemAllocVar(size_t cbUnaligned)
     167RT_EXPORT_SYMBOL(RTMemAllocZTag);
     168
     169
     170RTDECL(void *) RTMemAllocVarTag(size_t cbUnaligned, const char *pszTag)
    197171{
    198172    size_t cbAligned;
     
    201175    else
    202176        cbAligned = RT_ALIGN_Z(cbUnaligned, sizeof(void *));
    203     return RTMemAlloc(cbAligned);
    204 }
    205 RT_EXPORT_SYMBOL(RTMemAllocVar);
    206 
    207 
    208 /**
    209  * Wrapper around RTMemAllocZ for automatically aligning variable sized
    210  * allocations so that the various electric fence heaps works correctly.
    211  *
    212  * @returns See RTMemAllocZ.
    213  * @param   cbUnaligned         The unaligned size.
    214  */
    215 RTDECL(void *) RTMemAllocZVar(size_t cbUnaligned)
     177    return RTMemAllocTag(cbAligned, pszTag);
     178}
     179RT_EXPORT_SYMBOL(RTMemAllocVarTag);
     180
     181
     182RTDECL(void *) RTMemAllocZVarTag(size_t cbUnaligned, const char *pszTag)
    216183{
    217184    size_t cbAligned;
     
    220187    else
    221188        cbAligned = RT_ALIGN_Z(cbUnaligned, sizeof(void *));
    222     return RTMemAllocZ(cbAligned);
    223 }
    224 RT_EXPORT_SYMBOL(RTMemAllocZVar);
    225 
    226 
    227 /**
    228  * Reallocates memory.
    229  *
    230  * @returns Pointer to the allocated memory.
    231  * @returns NULL on failure.
    232  * @param   pvOld   The memory block to reallocate.
    233  * @param   cbNew   The new block size (in bytes).
    234  */
    235 RTDECL(void *) RTMemRealloc(void *pvOld, size_t cbNew) RT_NO_THROW
     189    return RTMemAllocZTag(cbAligned, pszTag);
     190}
     191RT_EXPORT_SYMBOL(RTMemAllocZVarTag);
     192
     193
     194RTDECL(void *) RTMemReallocTag(void *pvOld, size_t cbNew, const char *pszTag) RT_NO_THROW
    236195{
    237196    if (!cbNew)
    238197        RTMemFree(pvOld);
    239198    else if (!pvOld)
    240         return RTMemAlloc(cbNew);
     199        return RTMemAllocTag(cbNew, pszTag);
    241200    else
    242201    {
     
    275234    return NULL;
    276235}
    277 RT_EXPORT_SYMBOL(RTMemRealloc);
    278 
    279 
    280 /**
    281  * Free memory related to an virtual machine
    282  *
    283  * @param   pv      Pointer to memory block.
    284  */
     236RT_EXPORT_SYMBOL(RTMemReallocTag);
     237
     238
    285239RTDECL(void) RTMemFree(void *pv) RT_NO_THROW
    286240{
     
    311265
    312266
    313 /**
    314  * Allocates memory which may contain code.
    315  *
    316  * @returns Pointer to the allocated memory.
    317  * @returns NULL on failure.
    318  * @param   cb      Size in bytes of the memory block to allocate.
    319  */
    320 RTDECL(void *)    RTMemExecAlloc(size_t cb) RT_NO_THROW
     267
     268
     269
     270
     271RTDECL(void *)    RTMemExecAllocTag(size_t cb, const char *pszTag) RT_NO_THROW
    321272{
    322273    PRTMEMHDR pHdr;
     
    338289    return NULL;
    339290}
    340 RT_EXPORT_SYMBOL(RTMemExecAlloc);
    341 
    342 
    343 /**
    344  * Free executable/read/write memory allocated by RTMemExecAlloc().
    345  *
    346  * @param   pv      Pointer to memory block.
    347  */
     291RT_EXPORT_SYMBOL(RTMemExecAllocTag);
     292
     293
    348294RTDECL(void)      RTMemExecFree(void *pv) RT_NO_THROW
    349295{
  • trunk/src/VBox/Runtime/r0drv/memobj-r0drv.cpp

    r29027 r31157  
    55
    66/*
    7  * Copyright (C) 2006-2007 Oracle Corporation
     7 * Copyright (C) 2006-2010 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    405405
    406406
    407 /**
    408  * Allocates page aligned virtual kernel memory.
    409  *
    410  * The memory is taken from a non paged (= fixed physical memory backing) pool.
    411  *
    412  * @returns IPRT status code.
    413  * @param   pMemObj         Where to store the ring-0 memory object handle.
    414  * @param   cb              Number of bytes to allocate. This is rounded up to nearest page.
    415  * @param   fExecutable     Flag indicating whether it should be permitted to executed code in the memory object.
    416  */
    417 RTR0DECL(int) RTR0MemObjAllocPage(PRTR0MEMOBJ pMemObj, size_t cb, bool fExecutable)
     407RTR0DECL(int) RTR0MemObjAllocPageTag(PRTR0MEMOBJ pMemObj, size_t cb, bool fExecutable, const char *pszTag)
    418408{
    419409    /* sanity checks. */
     
    428418    return rtR0MemObjNativeAllocPage(pMemObj, cbAligned, fExecutable);
    429419}
    430 RT_EXPORT_SYMBOL(RTR0MemObjAllocPage);
    431 
    432 
    433 /**
    434  * Allocates page aligned virtual kernel memory with physical backing below 4GB.
    435  *
    436  * The physical memory backing the allocation is fixed.
    437  *
    438  * @returns IPRT status code.
    439  * @param   pMemObj         Where to store the ring-0 memory object handle.
    440  * @param   cb              Number of bytes to allocate. This is rounded up to nearest page.
    441  * @param   fExecutable     Flag indicating whether it should be permitted to executed code in the memory object.
    442  */
    443 RTR0DECL(int) RTR0MemObjAllocLow(PRTR0MEMOBJ pMemObj, size_t cb, bool fExecutable)
     420RT_EXPORT_SYMBOL(RTR0MemObjAllocPageTag);
     421
     422
     423RTR0DECL(int) RTR0MemObjAllocLowTag(PRTR0MEMOBJ pMemObj, size_t cb, bool fExecutable, const char *pszTag)
    444424{
    445425    /* sanity checks. */
     
    454434    return rtR0MemObjNativeAllocLow(pMemObj, cbAligned, fExecutable);
    455435}
    456 RT_EXPORT_SYMBOL(RTR0MemObjAllocLow);
    457 
    458 
    459 /**
    460  * Allocates page aligned virtual kernel memory with contiguous physical backing below 4GB.
    461  *
    462  * The physical memory backing the allocation is fixed.
    463  *
    464  * @returns IPRT status code.
    465  * @param   pMemObj         Where to store the ring-0 memory object handle.
    466  * @param   cb              Number of bytes to allocate. This is rounded up to nearest page.
    467  * @param   fExecutable     Flag indicating whether it should be permitted to executed code in the memory object.
    468  */
    469 RTR0DECL(int) RTR0MemObjAllocCont(PRTR0MEMOBJ pMemObj, size_t cb, bool fExecutable)
     436RT_EXPORT_SYMBOL(RTR0MemObjAllocLowTag);
     437
     438
     439RTR0DECL(int) RTR0MemObjAllocContTag(PRTR0MEMOBJ pMemObj, size_t cb, bool fExecutable, const char *pszTag)
    470440{
    471441    /* sanity checks. */
     
    480450    return rtR0MemObjNativeAllocCont(pMemObj, cbAligned, fExecutable);
    481451}
    482 RT_EXPORT_SYMBOL(RTR0MemObjAllocCont);
    483 
    484 
    485 /**
    486  * Locks a range of user virtual memory.
    487  *
    488  * @returns IPRT status code.
    489  * @param   pMemObj         Where to store the ring-0 memory object handle.
    490  * @param   R3Ptr           User virtual address. This is rounded down to a page
    491  *                          boundrary.
    492  * @param   cb              Number of bytes to lock. This is rounded up to
    493  *                          nearest page boundrary.
    494  * @param   fAccess         The desired access, a combination of RTMEM_PROT_READ
    495  *                          and RTMEM_PROT_WRITE.
    496  * @param   R0Process       The process to lock pages in. NIL_RTR0PROCESS is an
    497  *                          alias for the current one.
    498  *
    499  * @remarks RTR0MemGetAddressR3() and RTR0MemGetAddress() will return therounded
    500  *          down address.
    501  *
    502  * @remarks Linux: This API requires that the memory begin locked is in a memory
    503  *          mapping that is not required in any forked off child process. This
    504  *          is not intented as permanent restriction, feel free to help out
    505  *          lifting it.
    506  */
    507 RTR0DECL(int) RTR0MemObjLockUser(PRTR0MEMOBJ pMemObj, RTR3PTR R3Ptr, size_t cb, uint32_t fAccess, RTR0PROCESS R0Process)
     452RT_EXPORT_SYMBOL(RTR0MemObjAllocContTag);
     453
     454
     455RTR0DECL(int) RTR0MemObjLockUserTag(PRTR0MEMOBJ pMemObj, RTR3PTR R3Ptr, size_t cb,
     456                                    uint32_t fAccess, RTR0PROCESS R0Process, const char *pszTag)
    508457{
    509458    /* sanity checks. */
     
    523472    return rtR0MemObjNativeLockUser(pMemObj, R3PtrAligned, cbAligned, fAccess, R0Process);
    524473}
    525 RT_EXPORT_SYMBOL(RTR0MemObjLockUser);
    526 
    527 
    528 /**
    529  * Locks a range of kernel virtual memory.
    530  *
    531  * @returns IPRT status code.
    532  * @param   pMemObj         Where to store the ring-0 memory object handle.
    533  * @param   pv              Kernel virtual address. This is rounded down to a page boundrary.
    534  * @param   cb              Number of bytes to lock. This is rounded up to nearest page boundrary.
    535  * @param   fAccess         The desired access, a combination of RTMEM_PROT_READ
    536  *                          and RTMEM_PROT_WRITE.
    537  *
    538  * @remark  RTR0MemGetAddress() will return the rounded down address.
    539  */
    540 RTR0DECL(int) RTR0MemObjLockKernel(PRTR0MEMOBJ pMemObj, void *pv, size_t cb, uint32_t fAccess)
     474RT_EXPORT_SYMBOL(RTR0MemObjLockUserTag);
     475
     476
     477RTR0DECL(int) RTR0MemObjLockKernelTag(PRTR0MEMOBJ pMemObj, void *pv, size_t cb, uint32_t fAccess, const char *pszTag)
    541478{
    542479    /* sanity checks. */
     
    555492    return rtR0MemObjNativeLockKernel(pMemObj, pvAligned, cbAligned, fAccess);
    556493}
    557 RT_EXPORT_SYMBOL(RTR0MemObjLockKernel);
    558 
    559 
    560 /**
    561  * Allocates contiguous page aligned physical memory without (necessarily) any kernel mapping.
    562  *
    563  * @returns IPRT status code.
    564  * @param   pMemObj         Where to store the ring-0 memory object handle.
    565  * @param   cb              Number of bytes to allocate. This is rounded up to nearest page.
    566  * @param   PhysHighest     The highest permittable address (inclusive).
    567  *                          Pass NIL_RTHCPHYS if any address is acceptable.
    568  */
    569 RTR0DECL(int) RTR0MemObjAllocPhys(PRTR0MEMOBJ pMemObj, size_t cb, RTHCPHYS PhysHighest)
     494RT_EXPORT_SYMBOL(RTR0MemObjLockKernelTag);
     495
     496
     497RTR0DECL(int) RTR0MemObjAllocPhysTag(PRTR0MEMOBJ pMemObj, size_t cb, RTHCPHYS PhysHighest, const char *pszTag)
    570498{
    571499    /* sanity checks. */
     
    581509    return rtR0MemObjNativeAllocPhys(pMemObj, cbAligned, PhysHighest, PAGE_SIZE /* page aligned */);
    582510}
    583 RT_EXPORT_SYMBOL(RTR0MemObjAllocPhys);
    584 
    585 
    586 /**
    587  * Allocates contiguous physical memory without (necessarily) any kernel mapping.
    588  *
    589  * @returns IPRT status code.
    590  * @param   pMemObj         Where to store the ring-0 memory object handle.
    591  * @param   cb              Number of bytes to allocate. This is rounded up to nearest page.
    592  * @param   PhysHighest     The highest permittable address (inclusive).
    593  *                          Pass NIL_RTHCPHYS if any address is acceptable.
    594  * @param   uAlignment      The alignment of the physical memory to allocate.
    595  *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M, _4M and _1G.
    596  */
    597 RTR0DECL(int) RTR0MemObjAllocPhysEx(PRTR0MEMOBJ pMemObj, size_t cb, RTHCPHYS PhysHighest, size_t uAlignment)
     511RT_EXPORT_SYMBOL(RTR0MemObjAllocPhysTag);
     512
     513
     514RTR0DECL(int) RTR0MemObjAllocPhysExTag(PRTR0MEMOBJ pMemObj, size_t cb, RTHCPHYS PhysHighest, size_t uAlignment, const char *pszTag)
    598515{
    599516    /* sanity checks. */
     
    622539    return rtR0MemObjNativeAllocPhys(pMemObj, cbAligned, PhysHighest, uAlignment);
    623540}
    624 RT_EXPORT_SYMBOL(RTR0MemObjAllocPhysEx);
    625 
    626 
    627 /**
    628  * Allocates non-contiguous page aligned physical memory without (necessarily) any kernel mapping.
    629  *
    630  * @returns IPRT status code.
    631  * @param   pMemObj         Where to store the ring-0 memory object handle.
    632  * @param   cb              Number of bytes to allocate. This is rounded up to nearest page.
    633  * @param   PhysHighest     The highest permittable address (inclusive).
    634  *                          Pass NIL_RTHCPHYS if any address is acceptable.
    635  */
    636 RTR0DECL(int) RTR0MemObjAllocPhysNC(PRTR0MEMOBJ pMemObj, size_t cb, RTHCPHYS PhysHighest)
     541RT_EXPORT_SYMBOL(RTR0MemObjAllocPhysExTag);
     542
     543
     544RTR0DECL(int) RTR0MemObjAllocPhysNCTag(PRTR0MEMOBJ pMemObj, size_t cb, RTHCPHYS PhysHighest, const char *pszTag)
    637545{
    638546    /* sanity checks. */
     
    648556    return rtR0MemObjNativeAllocPhysNC(pMemObj, cbAligned, PhysHighest);
    649557}
    650 RT_EXPORT_SYMBOL(RTR0MemObjAllocPhysNC);
    651 
    652 
    653 /**
    654  * Creates a page aligned, contiguous, physical memory object.
    655  *
    656  * No physical memory is allocated, we trust you do know what you're doing.
    657  *
    658  * @returns IPRT status code.
    659  * @param   pMemObj         Where to store the ring-0 memory object handle.
    660  * @param   Phys            The physical address to start at. This is rounded down to the
    661  *                          nearest page boundrary.
    662  * @param   cb              The size of the object in bytes. This is rounded up to nearest page boundrary.
    663  * @param   uCachePolicy    One of the RTMEM_CACHE_XXX modes.
    664  */
    665 RTR0DECL(int) RTR0MemObjEnterPhys(PRTR0MEMOBJ pMemObj, RTHCPHYS Phys, size_t cb, uint32_t uCachePolicy)
     558RT_EXPORT_SYMBOL(RTR0MemObjAllocPhysNCTag);
     559
     560
     561RTR0DECL(int) RTR0MemObjEnterPhysTag(PRTR0MEMOBJ pMemObj, RTHCPHYS Phys, size_t cb, uint32_t uCachePolicy, const char *pszTag)
    666562{
    667563    /* sanity checks. */
     
    681577    return rtR0MemObjNativeEnterPhys(pMemObj, PhysAligned, cbAligned, uCachePolicy);
    682578}
    683 RT_EXPORT_SYMBOL(RTR0MemObjEnterPhys);
    684 
    685 
    686 /**
    687  * Reserves kernel virtual address space.
    688  *
    689  * @returns IPRT status code.
    690  * @param   pMemObj         Where to store the ring-0 memory object handle.
    691  * @param   pvFixed         Requested address. (void *)-1 means any address. This must match the alignment.
    692  * @param   cb              The number of bytes to reserve. This is rounded up to nearest page.
    693  * @param   uAlignment      The alignment of the reserved memory.
    694  *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M and _4M.
    695  */
    696 RTR0DECL(int) RTR0MemObjReserveKernel(PRTR0MEMOBJ pMemObj, void *pvFixed, size_t cb, size_t uAlignment)
     579RT_EXPORT_SYMBOL(RTR0MemObjEnterPhysTag);
     580
     581
     582RTR0DECL(int) RTR0MemObjReserveKernelTag(PRTR0MEMOBJ pMemObj, void *pvFixed, size_t cb, size_t uAlignment, const char *pszTag)
    697583{
    698584    /* sanity checks. */
     
    712598    return rtR0MemObjNativeReserveKernel(pMemObj, pvFixed, cbAligned, uAlignment);
    713599}
    714 RT_EXPORT_SYMBOL(RTR0MemObjReserveKernel);
    715 
    716 
    717 /**
    718  * Reserves user virtual address space in the current process.
    719  *
    720  * @returns IPRT status code.
    721  * @param   pMemObj         Where to store the ring-0 memory object handle.
    722  * @param   R3PtrFixed      Requested address. (RTR3PTR)-1 means any address. This must match the alignment.
    723  * @param   cb              The number of bytes to reserve. This is rounded up to nearest PAGE_SIZE.
    724  * @param   uAlignment      The alignment of the reserved memory.
    725  *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M and _4M.
    726  * @param   R0Process       The process to reserve the memory in. NIL_RTR0PROCESS is an alias for the current one.
    727  */
    728 RTR0DECL(int) RTR0MemObjReserveUser(PRTR0MEMOBJ pMemObj, RTR3PTR R3PtrFixed, size_t cb, size_t uAlignment, RTR0PROCESS R0Process)
     600RT_EXPORT_SYMBOL(RTR0MemObjReserveKernelTag);
     601
     602
     603RTR0DECL(int) RTR0MemObjReserveUserTag(PRTR0MEMOBJ pMemObj, RTR3PTR R3PtrFixed, size_t cb,
     604                                       size_t uAlignment, RTR0PROCESS R0Process, const char *pszTag)
    729605{
    730606    /* sanity checks. */
     
    746622    return rtR0MemObjNativeReserveUser(pMemObj, R3PtrFixed, cbAligned, uAlignment, R0Process);
    747623}
    748 RT_EXPORT_SYMBOL(RTR0MemObjReserveUser);
    749 
    750 
    751 /**
    752  * Maps a memory object into kernel virtual address space.
    753  *
    754  * @returns IPRT status code.
    755  * @param   pMemObj         Where to store the ring-0 memory object handle of the mapping object.
    756  * @param   MemObjToMap     The object to be map.
    757  * @param   pvFixed         Requested address. (void *)-1 means any address. This must match the alignment.
    758  * @param   uAlignment      The alignment of the reserved memory.
    759  *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M and _4M.
    760  * @param   fProt           Combination of RTMEM_PROT_* flags (except RTMEM_PROT_NONE).
    761  */
    762 RTR0DECL(int) RTR0MemObjMapKernel(PRTR0MEMOBJ pMemObj, RTR0MEMOBJ MemObjToMap, void *pvFixed, size_t uAlignment, unsigned fProt)
    763 {
    764     return RTR0MemObjMapKernelEx(pMemObj, MemObjToMap, pvFixed, uAlignment, fProt, 0, 0);
    765 }
    766 RT_EXPORT_SYMBOL(RTR0MemObjMapKernel);
    767 
    768 
    769 /**
    770  * Maps a memory object into kernel virtual address space.
    771  *
    772  * The ability to map subsections of the object into kernel space is currently
    773  * not implemented on all platforms. All/Most of platforms supports mapping the
    774  * whole object into  kernel space.
    775  *
    776  * @returns IPRT status code.
    777  * @retval  VERR_NOT_SUPPORTED if it's not possible to map a subsection of a
    778  *          memory object on this platform. When you hit this, try implement it.
    779  *
    780  * @param   pMemObj         Where to store the ring-0 memory object handle of the mapping object.
    781  * @param   MemObjToMap     The object to be map.
    782  * @param   pvFixed         Requested address. (void *)-1 means any address. This must match the alignment.
    783  * @param   uAlignment      The alignment of the reserved memory.
    784  *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M and _4M.
    785  * @param   fProt           Combination of RTMEM_PROT_* flags (except RTMEM_PROT_NONE).
    786  * @param   offSub          Where in the object to start mapping. If non-zero
    787  *                          the value must be page aligned and cbSub must be
    788  *                          non-zero as well.
    789  * @param   cbSub           The size of the part of the object to be mapped. If
    790  *                          zero the entire object is mapped. The value must be
    791  *                          page aligned.
    792  */
    793 RTR0DECL(int) RTR0MemObjMapKernelEx(PRTR0MEMOBJ pMemObj, RTR0MEMOBJ MemObjToMap, void *pvFixed, size_t uAlignment,
    794                                     unsigned fProt, size_t offSub, size_t cbSub)
     624RT_EXPORT_SYMBOL(RTR0MemObjReserveUserTag);
     625
     626
     627RTR0DECL(int) RTR0MemObjMapKernelTag(PRTR0MEMOBJ pMemObj, RTR0MEMOBJ MemObjToMap, void *pvFixed,
     628                                     size_t uAlignment, unsigned fProt, const char *pszTag)
     629{
     630    return RTR0MemObjMapKernelExTag(pMemObj, MemObjToMap, pvFixed, uAlignment, fProt, 0, 0, pszTag);
     631}
     632RT_EXPORT_SYMBOL(RTR0MemObjMapKernelTag);
     633
     634
     635RTR0DECL(int) RTR0MemObjMapKernelExTag(PRTR0MEMOBJ pMemObj, RTR0MEMOBJ MemObjToMap, void *pvFixed, size_t uAlignment,
     636                                       unsigned fProt, size_t offSub, size_t cbSub, const char *pszTag)
    795637{
    796638    PRTR0MEMOBJINTERNAL pMemToMap;
     
    846688    return rc;
    847689}
    848 RT_EXPORT_SYMBOL(RTR0MemObjMapKernelEx);
    849 
    850 
    851 /**
    852  * Maps a memory object into user virtual address space in the current process.
    853  *
    854  * @returns IPRT status code.
    855  * @param   pMemObj         Where to store the ring-0 memory object handle of the mapping object.
    856  * @param   MemObjToMap     The object to be map.
    857  * @param   R3PtrFixed      Requested address. (RTR3PTR)-1 means any address. This must match the alignment.
    858  * @param   uAlignment      The alignment of the reserved memory.
    859  *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M and _4M.
    860  * @param   fProt           Combination of RTMEM_PROT_* flags (except RTMEM_PROT_NONE).
    861  * @param   R0Process       The process to map the memory into. NIL_RTR0PROCESS is an alias for the current one.
    862  */
    863 RTR0DECL(int) RTR0MemObjMapUser(PRTR0MEMOBJ pMemObj, RTR0MEMOBJ MemObjToMap, RTR3PTR R3PtrFixed, size_t uAlignment, unsigned fProt, RTR0PROCESS R0Process)
     690RT_EXPORT_SYMBOL(RTR0MemObjMapKernelExTag);
     691
     692
     693RTR0DECL(int) RTR0MemObjMapUserTag(PRTR0MEMOBJ pMemObj, RTR0MEMOBJ MemObjToMap, RTR3PTR R3PtrFixed,
     694                                   size_t uAlignment, unsigned fProt, RTR0PROCESS R0Process, const char *pszTag)
    864695{
    865696    /* sanity checks. */
     
    907738    return rc;
    908739}
    909 RT_EXPORT_SYMBOL(RTR0MemObjMapUser);
     740RT_EXPORT_SYMBOL(RTR0MemObjMapUserTag);
    910741
    911742
  • trunk/src/VBox/Runtime/r3/alloc-ef-cpp.cpp

    r28800 r31157  
    5858void *RT_EF_CDECL operator new(RT_EF_SIZE_T cb) throw(std::bad_alloc)
    5959{
    60     void *pv = rtR3MemAlloc("new", RTMEMTYPE_NEW, cb, cb, ASMReturnAddress(), NULL, 0, NULL);
     60    void *pv = rtR3MemAlloc("new", RTMEMTYPE_NEW, cb, cb, NULL, ASMReturnAddress(), NULL, 0, NULL);
    6161    if (!pv)
    6262        throw std::bad_alloc();
     
    6767void *RT_EF_CDECL operator new(RT_EF_SIZE_T cb, const std::nothrow_t &) throw()
    6868{
    69     void *pv = rtR3MemAlloc("new nothrow", RTMEMTYPE_NEW, cb, cb, ASMReturnAddress(), NULL, 0, NULL);
     69    void *pv = rtR3MemAlloc("new nothrow", RTMEMTYPE_NEW, cb, cb, NULL, ASMReturnAddress(), NULL, 0, NULL);
    7070    return pv;
    7171}
     
    9494void *RT_EF_CDECL operator new[](RT_EF_SIZE_T cb) throw(std::bad_alloc)
    9595{
    96     void *pv = rtR3MemAlloc("new[]", RTMEMTYPE_NEW_ARRAY, cb, cb, ASMReturnAddress(), NULL, 0, NULL);
     96    void *pv = rtR3MemAlloc("new[]", RTMEMTYPE_NEW_ARRAY, cb, cb, NULL, ASMReturnAddress(), NULL, 0, NULL);
    9797    if (!pv)
    9898        throw std::bad_alloc();
     
    103103void * RT_EF_CDECL operator new[](RT_EF_SIZE_T cb, const std::nothrow_t &) throw()
    104104{
    105     void *pv = rtR3MemAlloc("new[] nothrow", RTMEMTYPE_NEW_ARRAY, cb, cb, ASMReturnAddress(), NULL, 0, NULL);
     105    void *pv = rtR3MemAlloc("new[] nothrow", RTMEMTYPE_NEW_ARRAY, cb, cb, NULL, ASMReturnAddress(), NULL, 0, NULL);
    106106    return pv;
    107107}
  • trunk/src/VBox/Runtime/r3/alloc-ef.cpp

    r28800 r31157  
    127127 */
    128128DECLINLINE(PRTMEMBLOCK) rtmemBlockCreate(RTMEMTYPE enmType, size_t cbUnaligned, size_t cbAligned,
    129                                          void *pvCaller, RT_SRC_POS_DECL)
     129                                         const char *pszTag, void *pvCaller, RT_SRC_POS_DECL)
    130130{
    131131    PRTMEMBLOCK pBlock = (PRTMEMBLOCK)malloc(sizeof(*pBlock));
     
    135135        pBlock->cbUnaligned = cbUnaligned;
    136136        pBlock->cbAligned   = cbAligned;
     137        pBlock->pszTag      = pszTag;
    137138        pBlock->pvCaller    = pvCaller;
    138139        pBlock->iLine       = iLine;
     
    273274 */
    274275RTDECL(void *) rtR3MemAlloc(const char *pszOp, RTMEMTYPE enmType, size_t cbUnaligned, size_t cbAligned,
    275                             void *pvCaller, RT_SRC_POS_DECL)
     276                            const char *pszTag, void *pvCaller, RT_SRC_POS_DECL)
    276277{
    277278    /*
     
    305306     * Allocate the trace block.
    306307     */
    307     PRTMEMBLOCK pBlock = rtmemBlockCreate(enmType, cbUnaligned, cbAligned, pvCaller, RT_SRC_POS_ARGS);
     308    PRTMEMBLOCK pBlock = rtmemBlockCreate(enmType, cbUnaligned, cbAligned, pszTag, pvCaller, RT_SRC_POS_ARGS);
    308309    if (!pBlock)
    309310    {
     
    503504 * Internal realloc.
    504505 */
    505 RTDECL(void *) rtR3MemRealloc(const char *pszOp, RTMEMTYPE enmType, void *pvOld, size_t cbNew, void *pvCaller, RT_SRC_POS_DECL)
     506RTDECL(void *) rtR3MemRealloc(const char *pszOp, RTMEMTYPE enmType, void *pvOld, size_t cbNew,
     507                              const char *pszTag, void *pvCaller, RT_SRC_POS_DECL)
    506508{
    507509    /*
     
    509511     */
    510512    if (!pvOld)
    511         return rtR3MemAlloc(pszOp, enmType, cbNew, cbNew, pvCaller, RT_SRC_POS_ARGS);
     513        return rtR3MemAlloc(pszOp, enmType, cbNew, cbNew, pszTag, pvCaller, RT_SRC_POS_ARGS);
    512514    if (!cbNew)
    513515    {
     
    524526    if (pBlock)
    525527    {
    526         void *pvRet = rtR3MemAlloc(pszOp, enmType, cbNew, cbNew, pvCaller, RT_SRC_POS_ARGS);
     528        void *pvRet = rtR3MemAlloc(pszOp, enmType, cbNew, cbNew, pszTag, pvCaller, RT_SRC_POS_ARGS);
    527529        if (pvRet)
    528530        {
     
    547549
    548550
    549 RTDECL(void *)  RTMemEfTmpAlloc(size_t cb, RT_SRC_POS_DECL) RT_NO_THROW
    550 {
    551     return rtR3MemAlloc("TmpAlloc", RTMEMTYPE_RTMEMALLOC, cb, cb, ASMReturnAddress(), RT_SRC_POS_ARGS);
    552 }
    553 
    554 
    555 RTDECL(void *)  RTMemEfTmpAllocZ(size_t cb, RT_SRC_POS_DECL) RT_NO_THROW
    556 {
    557     return rtR3MemAlloc("TmpAlloc", RTMEMTYPE_RTMEMALLOCZ, cb, cb, ASMReturnAddress(), RT_SRC_POS_ARGS);
     551RTDECL(void *)  RTMemEfTmpAlloc(size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW
     552{
     553    return rtR3MemAlloc("TmpAlloc", RTMEMTYPE_RTMEMALLOC, cb, cb, pszTag, ASMReturnAddress(), RT_SRC_POS_ARGS);
     554}
     555
     556
     557RTDECL(void *)  RTMemEfTmpAllocZ(size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW
     558{
     559    return rtR3MemAlloc("TmpAlloc", RTMEMTYPE_RTMEMALLOCZ, cb, cb, pszTag, ASMReturnAddress(), RT_SRC_POS_ARGS);
    558560}
    559561
     
    566568
    567569
    568 RTDECL(void *)  RTMemEfAlloc(size_t cb, RT_SRC_POS_DECL) RT_NO_THROW
    569 {
    570     return rtR3MemAlloc("Alloc", RTMEMTYPE_RTMEMALLOC, cb, cb, ASMReturnAddress(), RT_SRC_POS_ARGS);
    571 }
    572 
    573 
    574 RTDECL(void *)  RTMemEfAllocZ(size_t cb, RT_SRC_POS_DECL) RT_NO_THROW
    575 {
    576     return rtR3MemAlloc("AllocZ", RTMEMTYPE_RTMEMALLOCZ, cb, cb, ASMReturnAddress(), RT_SRC_POS_ARGS);
    577 }
    578 
    579 
    580 RTDECL(void *)  RTMemEfAllocVar(size_t cbUnaligned, RT_SRC_POS_DECL) RT_NO_THROW
     570RTDECL(void *)  RTMemEfAlloc(size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW
     571{
     572    return rtR3MemAlloc("Alloc", RTMEMTYPE_RTMEMALLOC, cb, cb, pszTag, ASMReturnAddress(), RT_SRC_POS_ARGS);
     573}
     574
     575
     576RTDECL(void *)  RTMemEfAllocZ(size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW
     577{
     578    return rtR3MemAlloc("AllocZ", RTMEMTYPE_RTMEMALLOCZ, cb, cb, pszTag, ASMReturnAddress(), RT_SRC_POS_ARGS);
     579}
     580
     581
     582RTDECL(void *)  RTMemEfAllocVar(size_t cbUnaligned, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW
    581583{
    582584    size_t cbAligned;
     
    585587    else
    586588        cbAligned = RT_ALIGN_Z(cbUnaligned, sizeof(void *));
    587     return rtR3MemAlloc("Alloc", RTMEMTYPE_RTMEMALLOC, cbUnaligned, cbAligned, ASMReturnAddress(), RT_SRC_POS_ARGS);
    588 }
    589 
    590 
    591 RTDECL(void *)  RTMemEfAllocZVar(size_t cbUnaligned, RT_SRC_POS_DECL) RT_NO_THROW
     589    return rtR3MemAlloc("Alloc", RTMEMTYPE_RTMEMALLOC, cbUnaligned, cbAligned, pszTag, ASMReturnAddress(), RT_SRC_POS_ARGS);
     590}
     591
     592
     593RTDECL(void *)  RTMemEfAllocZVar(size_t cbUnaligned, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW
    592594{
    593595    size_t cbAligned;
     
    596598    else
    597599        cbAligned = RT_ALIGN_Z(cbUnaligned, sizeof(void *));
    598     return rtR3MemAlloc("AllocZ", RTMEMTYPE_RTMEMALLOCZ, cbUnaligned, cbAligned, ASMReturnAddress(), RT_SRC_POS_ARGS);
    599 }
    600 
    601 
    602 RTDECL(void *)  RTMemEfRealloc(void *pvOld, size_t cbNew, RT_SRC_POS_DECL) RT_NO_THROW
    603 {
    604     return rtR3MemRealloc("Realloc", RTMEMTYPE_RTMEMREALLOC, pvOld, cbNew, ASMReturnAddress(), RT_SRC_POS_ARGS);
     600    return rtR3MemAlloc("AllocZ", RTMEMTYPE_RTMEMALLOCZ, cbUnaligned, cbAligned, pszTag, ASMReturnAddress(), RT_SRC_POS_ARGS);
     601}
     602
     603
     604RTDECL(void *)  RTMemEfRealloc(void *pvOld, size_t cbNew, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW
     605{
     606    return rtR3MemRealloc("Realloc", RTMEMTYPE_RTMEMREALLOC, pvOld, cbNew, pszTag, ASMReturnAddress(), RT_SRC_POS_ARGS);
    605607}
    606608
     
    613615
    614616
    615 RTDECL(void *) RTMemEfDup(const void *pvSrc, size_t cb, RT_SRC_POS_DECL) RT_NO_THROW
    616 {
    617     void *pvDst = RTMemEfAlloc(cb, RT_SRC_POS_ARGS);
     617RTDECL(void *) RTMemEfDup(const void *pvSrc, size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW
     618{
     619    void *pvDst = RTMemEfAlloc(cb, pszTag, RT_SRC_POS_ARGS);
    618620    if (pvDst)
    619621        memcpy(pvDst, pvSrc, cb);
     
    622624
    623625
    624 RTDECL(void *) RTMemEfDupEx(const void *pvSrc, size_t cbSrc, size_t cbExtra, RT_SRC_POS_DECL) RT_NO_THROW
    625 {
    626     void *pvDst = RTMemEfAlloc(cbSrc + cbExtra, RT_SRC_POS_ARGS);
     626RTDECL(void *) RTMemEfDupEx(const void *pvSrc, size_t cbSrc, size_t cbExtra, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW
     627{
     628    void *pvDst = RTMemEfAlloc(cbSrc + cbExtra, pszTag, RT_SRC_POS_ARGS);
    627629    if (pvDst)
    628630    {
     
    644646
    645647
    646 RTDECL(void *)  RTMemEfTmpAllocNP(size_t cb) RT_NO_THROW
    647 {
    648     return rtR3MemAlloc("TmpAlloc", RTMEMTYPE_RTMEMALLOC, cb, cb, ASMReturnAddress(), NULL, 0, NULL);
    649 }
    650 
    651 
    652 RTDECL(void *)  RTMemEfTmpAllocZNP(size_t cb) RT_NO_THROW
    653 {
    654     return rtR3MemAlloc("TmpAllocZ", RTMEMTYPE_RTMEMALLOCZ, cb, cb, ASMReturnAddress(), NULL, 0, NULL);
     648RTDECL(void *)  RTMemEfTmpAllocNP(size_t cb, const char *pszTag) RT_NO_THROW
     649{
     650    return rtR3MemAlloc("TmpAlloc", RTMEMTYPE_RTMEMALLOC, cb, cb, pszTag, ASMReturnAddress(), NULL, 0, NULL);
     651}
     652
     653
     654RTDECL(void *)  RTMemEfTmpAllocZNP(size_t cb, const char *pszTag) RT_NO_THROW
     655{
     656    return rtR3MemAlloc("TmpAllocZ", RTMEMTYPE_RTMEMALLOCZ, cb, cb, pszTag, ASMReturnAddress(), NULL, 0, NULL);
    655657}
    656658
     
    663665
    664666
    665 RTDECL(void *)  RTMemEfAllocNP(size_t cb) RT_NO_THROW
    666 {
    667     return rtR3MemAlloc("Alloc", RTMEMTYPE_RTMEMALLOC, cb, cb, ASMReturnAddress(), NULL, 0, NULL);
    668 }
    669 
    670 
    671 RTDECL(void *)  RTMemEfAllocZNP(size_t cb) RT_NO_THROW
    672 {
    673     return rtR3MemAlloc("AllocZ", RTMEMTYPE_RTMEMALLOCZ, cb, cb, ASMReturnAddress(), NULL, 0, NULL);
    674 }
    675 
    676 
    677 RTDECL(void *)  RTMemEfAllocVarNP(size_t cbUnaligned) RT_NO_THROW
     667RTDECL(void *)  RTMemEfAllocNP(size_t cb, const char *pszTag) RT_NO_THROW
     668{
     669    return rtR3MemAlloc("Alloc", RTMEMTYPE_RTMEMALLOC, cb, cb, pszTag, ASMReturnAddress(), NULL, 0, NULL);
     670}
     671
     672
     673RTDECL(void *)  RTMemEfAllocZNP(size_t cb, const char *pszTag) RT_NO_THROW
     674{
     675    return rtR3MemAlloc("AllocZ", RTMEMTYPE_RTMEMALLOCZ, cb, cb, pszTag, ASMReturnAddress(), NULL, 0, NULL);
     676}
     677
     678
     679RTDECL(void *)  RTMemEfAllocVarNP(size_t cbUnaligned, const char *pszTag) RT_NO_THROW
    678680{
    679681    size_t cbAligned;
     
    682684    else
    683685        cbAligned = RT_ALIGN_Z(cbUnaligned, sizeof(void *));
    684     return rtR3MemAlloc("Alloc", RTMEMTYPE_RTMEMALLOC, cbUnaligned, cbAligned, ASMReturnAddress(), NULL, 0, NULL);
    685 }
    686 
    687 
    688 RTDECL(void *)  RTMemEfAllocZVarNP(size_t cbUnaligned) RT_NO_THROW
     686    return rtR3MemAlloc("Alloc", RTMEMTYPE_RTMEMALLOC, cbUnaligned, cbAligned, pszTag, ASMReturnAddress(), NULL, 0, NULL);
     687}
     688
     689
     690RTDECL(void *)  RTMemEfAllocZVarNP(size_t cbUnaligned, const char *pszTag) RT_NO_THROW
    689691{
    690692    size_t cbAligned;
     
    693695    else
    694696        cbAligned = RT_ALIGN_Z(cbUnaligned, sizeof(void *));
    695     return rtR3MemAlloc("AllocZ", RTMEMTYPE_RTMEMALLOCZ, cbUnaligned, cbAligned, ASMReturnAddress(), NULL, 0, NULL);
    696 }
    697 
    698 
    699 RTDECL(void *)  RTMemEfReallocNP(void *pvOld, size_t cbNew) RT_NO_THROW
    700 {
    701     return rtR3MemRealloc("Realloc", RTMEMTYPE_RTMEMREALLOC, pvOld, cbNew, ASMReturnAddress(), NULL, 0, NULL);
     697    return rtR3MemAlloc("AllocZ", RTMEMTYPE_RTMEMALLOCZ, cbUnaligned, cbAligned, pszTag, ASMReturnAddress(), NULL, 0, NULL);
     698}
     699
     700
     701RTDECL(void *)  RTMemEfReallocNP(void *pvOld, size_t cbNew, const char *pszTag) RT_NO_THROW
     702{
     703    return rtR3MemRealloc("Realloc", RTMEMTYPE_RTMEMREALLOC, pvOld, cbNew, pszTag, ASMReturnAddress(), NULL, 0, NULL);
    702704}
    703705
     
    710712
    711713
    712 RTDECL(void *) RTMemEfDupNP(const void *pvSrc, size_t cb) RT_NO_THROW
    713 {
    714     void *pvDst = RTMemEfAlloc(cb, NULL, 0, NULL);
     714RTDECL(void *) RTMemEfDupNP(const void *pvSrc, size_t cb, const char *pszTag) RT_NO_THROW
     715{
     716    void *pvDst = RTMemEfAlloc(cb, pszTag, NULL, 0, NULL);
    715717    if (pvDst)
    716718        memcpy(pvDst, pvSrc, cb);
     
    719721
    720722
    721 RTDECL(void *) RTMemEfDupExNP(const void *pvSrc, size_t cbSrc, size_t cbExtra) RT_NO_THROW
    722 {
    723     void *pvDst = RTMemEfAlloc(cbSrc + cbExtra, NULL, 0, NULL);
     723RTDECL(void *) RTMemEfDupExNP(const void *pvSrc, size_t cbSrc, size_t cbExtra, const char *pszTag) RT_NO_THROW
     724{
     725    void *pvDst = RTMemEfAlloc(cbSrc + cbExtra, pszTag, NULL, 0, NULL);
    724726    if (pvDst)
    725727    {
  • trunk/src/VBox/Runtime/r3/alloc-ef.h

    r28800 r31157  
    166166    /** The aligned size of the block. */
    167167    size_t          cbAligned;
     168    /** The allocation tag (read-only string). */
     169    const char     *pszTag;
    168170    /** The return address of the allocator function. */
    169171    void           *pvCaller;
     
    184186RT_C_DECLS_BEGIN
    185187RTDECL(void *)  rtR3MemAlloc(const char *pszOp, RTMEMTYPE enmType, size_t cbUnaligned, size_t cbAligned,
    186                              void *pvCaller, RT_SRC_POS_DECL);
    187 RTDECL(void *)  rtR3MemRealloc(const char *pszOp, RTMEMTYPE enmType, void *pvOld, size_t cbNew, void *pvCaller, RT_SRC_POS_DECL);
     188                             const char *pszTag, void *pvCaller, RT_SRC_POS_DECL);
     189RTDECL(void *)  rtR3MemRealloc(const char *pszOp, RTMEMTYPE enmType, void *pvOld, size_t cbNew,
     190                               const char *pszTag, void *pvCaller, RT_SRC_POS_DECL);
    188191RTDECL(void)    rtR3MemFree(const char *pszOp, RTMEMTYPE enmType, void *pv, void *pvCaller, RT_SRC_POS_DECL);
    189192RT_C_DECLS_END
  • trunk/src/VBox/Runtime/r3/alloc.cpp

    r28800 r31157  
    55
    66/*
    7  * Copyright (C) 2006-2007 Oracle Corporation
     7 * Copyright (C) 2006-2010 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    4848
    4949#undef RTMemTmpAlloc
     50#undef RTMemTmpAllocTag
    5051#undef RTMemTmpAllocZ
     52#undef RTMemTmpAllocZTag
    5153#undef RTMemTmpFree
    5254#undef RTMemAlloc
     55#undef RTMemAllocTag
    5356#undef RTMemAllocZ
     57#undef RTMemAllocZTag
    5458#undef RTMemAllocVar
     59#undef RTMemAllocVarTag
    5560#undef RTMemAllocZVar
     61#undef RTMemAllocZVarTag
    5662#undef RTMemRealloc
     63#undef RTMemReallocTag
    5764#undef RTMemFree
    5865#undef RTMemDup
     66#undef RTMemDupTag
    5967#undef RTMemDupEx
     68#undef RTMemDupExTag
    6069
    6170
    62 /**
    63  * Allocates temporary memory.
    64  *
    65  * Temporary memory blocks are used for not too large memory blocks which
    66  * are believed not to stick around for too long. Using this API instead
    67  * of RTMemAlloc() not only gives the heap manager room for optimization
    68  * but makes the code easier to read.
    69  *
    70  * @returns Pointer to the allocated memory.
    71  * @returns NULL on failure.
    72  * @param   cb      Size in bytes of the memory block to allocate.
    73  */
    74 RTDECL(void *)  RTMemTmpAlloc(size_t cb) RT_NO_THROW
     71RTDECL(void *)  RTMemTmpAllocTag(size_t cb, const char *pszTag) RT_NO_THROW
    7572{
    76     return RTMemAlloc(cb);
     73    return RTMemAllocTag(cb, pszTag);
    7774}
    7875
    7976
    80 /**
    81  * Allocates zero'ed temporary memory.
    82  *
    83  * Same as RTMemTmpAlloc() but the memory will be zero'ed.
    84  *
    85  * @returns Pointer to the allocated memory.
    86  * @returns NULL on failure.
    87  * @param   cb      Size in bytes of the memory block to allocate.
    88  */
    89 RTDECL(void *)  RTMemTmpAllocZ(size_t cb) RT_NO_THROW
     77RTDECL(void *)  RTMemTmpAllocZTag(size_t cb, const char *pszTag) RT_NO_THROW
    9078{
    91     return RTMemAllocZ(cb);
     79    return RTMemAllocZTag(cb, pszTag);
    9280}
    9381
    9482
    95 /**
    96  * Free temporary memory.
    97  *
    98  * @param   pv      Pointer to memory block.
    99  */
    100 RTDECL(void)    RTMemTmpFree(void *pv) RT_NO_THROW
     83RTDECL(void) RTMemTmpFree(void *pv) RT_NO_THROW
    10184{
    10285    RTMemFree(pv);
     
    10487
    10588
    106 /**
    107  * Allocates memory.
    108  *
    109  * @returns Pointer to the allocated memory.
    110  * @returns NULL on failure.
    111  * @param   cb      Size in bytes of the memory block to allocate.
    112  */
    113 RTDECL(void *)  RTMemAlloc(size_t cb) RT_NO_THROW
     89RTDECL(void *) RTMemAllocTag(size_t cb, const char *pszTag) RT_NO_THROW
    11490{
    11591#ifdef RTALLOC_USE_EFENCE
    116     void *pv = rtR3MemAlloc("Alloc", RTMEMTYPE_RTMEMALLOC, cb, cb, ASMReturnAddress(), NULL, 0, NULL);
     92    void *pv = rtR3MemAlloc("Alloc", RTMEMTYPE_RTMEMALLOC, cb, cb, pszTag, ASMReturnAddress(), NULL, 0, NULL);
    11793
    11894#else /* !RTALLOC_USE_EFENCE */
     
    130106
    131107
    132 /**
    133  * Allocates zero'ed memory.
    134  *
    135  * Instead of memset(pv, 0, sizeof()) use this when you want zero'ed
    136  * memory. This keeps the code smaller and the heap can skip the memset
    137  * in about 0.42% of the calls :-).
    138  *
    139  * @returns Pointer to the allocated memory.
    140  * @returns NULL on failure.
    141  * @param   cb      Size in bytes of the memory block to allocate.
    142  */
    143 RTDECL(void *)  RTMemAllocZ(size_t cb) RT_NO_THROW
     108RTDECL(void *) RTMemAllocZTag(size_t cb, const char *pszTag) RT_NO_THROW
    144109{
    145110#ifdef RTALLOC_USE_EFENCE
    146     void *pv = rtR3MemAlloc("AllocZ", RTMEMTYPE_RTMEMALLOCZ, cb, cb, ASMReturnAddress(), NULL, 0, NULL);
     111    void *pv = rtR3MemAlloc("AllocZ", RTMEMTYPE_RTMEMALLOCZ, cb, cb, pszTag, ASMReturnAddress(), NULL, 0, NULL);
    147112
    148113#else /* !RTALLOC_USE_EFENCE */
     
    161126
    162127
    163 /**
    164  * Wrapper around RTMemAlloc for automatically aligning variable sized
    165  * allocations so that the various electric fence heaps works correctly.
    166  *
    167  * @returns See RTMemAlloc.
    168  * @param   cbUnaligned         The unaligned size.
    169  */
    170 RTDECL(void *) RTMemAllocVar(size_t cbUnaligned)
     128RTDECL(void *) RTMemAllocVarTag(size_t cbUnaligned, const char *pszTag) RT_NO_THROW
    171129{
    172130    size_t cbAligned;
     
    176134        cbAligned = RT_ALIGN_Z(cbUnaligned, sizeof(void *));
    177135#ifdef RTALLOC_USE_EFENCE
    178     void *pv = rtR3MemAlloc("AllocVar", RTMEMTYPE_RTMEMALLOC, cbUnaligned, cbAligned, ASMReturnAddress(), NULL, 0, NULL);
     136    void *pv = rtR3MemAlloc("AllocVar", RTMEMTYPE_RTMEMALLOC, cbUnaligned, cbAligned, pszTag, ASMReturnAddress(), NULL, 0, NULL);
    179137#else
    180     void *pv = RTMemAlloc(cbAligned);
     138    void *pv = RTMemAllocTag(cbAligned, pszTag);
    181139#endif
    182140    return pv;
     
    184142
    185143
    186 /**
    187  * Wrapper around RTMemAllocZ for automatically aligning variable sized
    188  * allocations so that the various electric fence heaps works correctly.
    189  *
    190  * @returns See RTMemAllocZ.
    191  * @param   cbUnaligned         The unaligned size.
    192  */
    193 RTDECL(void *) RTMemAllocZVar(size_t cbUnaligned)
     144RTDECL(void *) RTMemAllocZVarTag(size_t cbUnaligned, const char *pszTag) RT_NO_THROW
    194145{
    195146    size_t cbAligned;
     
    199150        cbAligned = RT_ALIGN_Z(cbUnaligned, sizeof(void *));
    200151#ifdef RTALLOC_USE_EFENCE
    201     void *pv = rtR3MemAlloc("AllocZVar", RTMEMTYPE_RTMEMALLOCZ, cbUnaligned, cbAligned, ASMReturnAddress(), NULL, 0, NULL);
     152    void *pv = rtR3MemAlloc("AllocZVar", RTMEMTYPE_RTMEMALLOCZ, cbUnaligned, cbAligned, pszTag, ASMReturnAddress(), NULL, 0, NULL);
    202153#else
    203     void *pv = RTMemAllocZ(cbAligned);
     154    void *pv = RTMemAllocZTag(cbAligned, pszTag);
    204155#endif
    205156    return pv;
     
    207158
    208159
    209 /**
    210  * Reallocates memory.
    211  *
    212  * @returns Pointer to the allocated memory.
    213  * @returns NULL on failure.
    214  * @param   pvOld   The memory block to reallocate.
    215  * @param   cbNew   The new block size (in bytes).
    216  */
    217 RTDECL(void *)  RTMemRealloc(void *pvOld, size_t cbNew) RT_NO_THROW
     160RTDECL(void *)  RTMemReallocTag(void *pvOld, size_t cbNew, const char *pszTag) RT_NO_THROW
    218161{
    219162#ifdef RTALLOC_USE_EFENCE
    220     void *pv = rtR3MemRealloc("Realloc", RTMEMTYPE_RTMEMREALLOC, pvOld, cbNew, ASMReturnAddress(), NULL, 0, NULL);
     163    void *pv = rtR3MemRealloc("Realloc", RTMEMTYPE_RTMEMREALLOC, pvOld, cbNew, pszTag, ASMReturnAddress(), NULL, 0, NULL);
    221164
    222165#else /* !RTALLOC_USE_EFENCE */
     
    233176
    234177
    235 /**
    236  * Free memory related to a virtual machine
    237  *
    238  * @param   pv      Pointer to memory block.
    239  */
    240 RTDECL(void)    RTMemFree(void *pv) RT_NO_THROW
     178RTDECL(void) RTMemFree(void *pv) RT_NO_THROW
    241179{
    242180    if (pv)
  • trunk/src/VBox/Runtime/r3/darwin/alloc-darwin.cpp

    r28800 r31157  
    55
    66/*
    7  * Copyright (C) 2006-2007 Oracle Corporation
     7 * Copyright (C) 2006-2010 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    4040
    4141
    42 /**
    43  * Allocates memory which may contain code.
    44  *
    45  * @returns Pointer to the allocated memory.
    46  * @returns NULL on failure.
    47  * @param   cb      Size in bytes of the memory block to allocate.
    48  */
    49 RTDECL(void *) RTMemExecAlloc(size_t cb) RT_NO_THROW
     42RTDECL(void *) RTMemExecAllocTag(size_t cb, const char *pszTag) RT_NO_THROW
    5043{
    5144    /*
     
    7467
    7568
    76 /**
    77  * Free executable/read/write memory allocated by RTMemExecAlloc().
    78  *
    79  * @param   pv      Pointer to memory block.
    80  */
    8169RTDECL(void)    RTMemExecFree(void *pv) RT_NO_THROW
    8270{
     
    8674
    8775
    88 /**
    89  * Allocate page aligned memory.
    90  *
    91  * @returns Pointer to the allocated memory.
    92  * @returns NULL if we're out of memory.
    93  * @param   cb  Size of the memory block. Will be rounded up to page size.
    94  */
    95 RTDECL(void *) RTMemPageAlloc(size_t cb) RT_NO_THROW
     76RTDECL(void *) RTMemPageAllocTag(size_t cb, const char *pszTag) RT_NO_THROW
    9677{
    9778    return valloc(RT_ALIGN_Z(cb, PAGE_SIZE));
     
    9980
    10081
    101 /**
    102  * Allocate zero'ed page aligned memory.
    103  *
    104  * @returns Pointer to the allocated memory.
    105  * @returns NULL if we're out of memory.
    106  * @param   cb  Size of the memory block. Will be rounded up to page size.
    107  */
    108 RTDECL(void *) RTMemPageAllocZ(size_t cb) RT_NO_THROW
     82RTDECL(void *) RTMemPageAllocZTag(size_t cb, const char *pszTag) RT_NO_THROW
    10983{
    11084    cb = RT_ALIGN_Z(cb, PAGE_SIZE);
     
    11690
    11791
    118 /**
    119  * Free a memory block allocated with RTMemPageAlloc() or RTMemPageAllocZ().
    120  *
    121  * @param   pv      Pointer to the block as it was returned by the allocation function.
    122  *                  NULL will be ignored.
    123  */
    12492RTDECL(void) RTMemPageFree(void *pv, size_t cb) RT_NO_THROW
    12593{
     
    12997
    13098
    131 /**
    132  * Change the page level protection of a memory region.
    133  *
    134  * @returns iprt status code.
    135  * @param   pv          Start of the region. Will be rounded down to nearest page boundary.
    136  * @param   cb          Size of the region. Will be rounded up to the nearest page boundary.
    137  * @param   fProtect    The new protection, a combination of the RTMEM_PROT_* defines.
    138  */
    13999RTDECL(int) RTMemProtect(void *pv, size_t cb, unsigned fProtect) RT_NO_THROW
    140100{
  • trunk/src/VBox/Runtime/r3/posix/utf8-posix.cpp

    r30294 r31157  
    413413
    414414
    415 /**
    416  * Allocates tmp buffer, translates pszString from UTF8 to current codepage.
    417  *
    418  * @returns iprt status code.
    419  * @param   ppszString      Receives pointer of allocated native CP string.
    420  *                          The returned pointer must be freed using RTStrFree().
    421  * @param   pszString       UTF-8 string to convert.
    422  */
    423 RTR3DECL(int)  RTStrUtf8ToCurrentCP(char **ppszString, const char *pszString)
     415RTR3DECL(int)  RTStrUtf8ToCurrentCPTag(char **ppszString, const char *pszString, const char *pszTag)
    424416{
    425417    Assert(ppszString);
     
    434426    {
    435427        /* zero length string passed. */
    436         *ppszString = (char *)RTMemTmpAllocZ(sizeof(char));
     428        *ppszString = (char *)RTMemTmpAllocZTag(sizeof(char), pszTag);
    437429        if (*ppszString)
    438430            return VINF_SUCCESS;
     
    443435
    444436
    445 /**
    446  * Allocates tmp buffer, translates pszString from current codepage to UTF-8.
    447  *
    448  * @returns iprt status code.
    449  * @param   ppszString      Receives pointer of allocated UTF-8 string.
    450  *                          The returned pointer must be freed using RTStrFree().
    451  * @param   pszString       Native string to convert.
    452  */
    453 RTR3DECL(int)  RTStrCurrentCPToUtf8(char **ppszString, const char *pszString)
     437RTR3DECL(int)  RTStrCurrentCPToUtf8Tag(char **ppszString, const char *pszString, const char *pszTag)
    454438{
    455439    Assert(ppszString);
     
    464448    {
    465449        /* zero length string passed. */
    466         *ppszString = (char *)RTMemTmpAllocZ(sizeof(char));
     450        *ppszString = (char *)RTMemTmpAllocZTag(sizeof(char), pszTag);
    467451        if (*ppszString)
    468452            return VINF_SUCCESS;
  • trunk/src/VBox/Runtime/r3/win/utf8-win.cpp

    r28800 r31157  
    55
    66/*
    7  * Copyright (C) 2006-2007 Oracle Corporation
     7 * Copyright (C) 2006-2010 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3838
    3939
    40 /**
    41  * Allocates tmp buffer, translates pszString from UTF8 to current codepage.
    42  *
    43  * @returns iprt status code.
    44  * @param   ppszString      Receives pointer of allocated native CP string.
    45  *                          The returned pointer must be freed using RTStrFree().
    46  * @param   pszString       UTF-8 string to convert.
    47  */
    48 RTR3DECL(int)  RTStrUtf8ToCurrentCP(char **ppszString, const char *pszString)
     40RTR3DECL(int)  RTStrUtf8ToCurrentCPTag(char **ppszString, const char *pszString, const char *pszTag)
    4941{
    5042    Assert(ppszString);
     
    5648    if (!*pszString)
    5749    {
    58         *ppszString = (char *)RTMemTmpAllocZ(sizeof(char));
     50        *ppszString = (char *)RTMemTmpAllocZTag(sizeof(char), pszTag);
    5951        if (*ppszString)
    6052            return VINF_SUCCESS;
     
    8173         * Alloc space for result buffer.
    8274         */
    83         LPSTR lpString = (LPSTR)RTMemTmpAlloc(cbResult);
     75        LPSTR lpString = (LPSTR)RTMemTmpAllocTag(cbResult, pszTag);
    8476        if (lpString)
    8577        {
     
    115107}
    116108
    117 /**
    118  * Allocates tmp buffer, translates pszString from current codepage to UTF-8.
    119  *
    120  * @returns iprt status code.
    121  * @param   ppszString      Receives pointer of allocated UTF-8 string.
    122  *                          The returned pointer must be freed using RTStrFree().
    123  * @param   pszString       Native string to convert.
    124  */
    125 RTR3DECL(int)  RTStrCurrentCPToUtf8(char **ppszString, const char *pszString)
     109
     110RTR3DECL(int)  RTStrCurrentCPToUtf8Tag(char **ppszString, const char *pszString, const char *pszTag)
    126111{
    127112    Assert(ppszString);
     
    135120    {
    136121        /* zero length string passed. */
    137         *ppszString = (char *)RTMemTmpAllocZ(sizeof(char));
     122        *ppszString = (char *)RTMemTmpAllocZTag(sizeof(char), pszTag);
    138123        if (*ppszString)
    139124            return VINF_SUCCESS;
  • trunk/src/VBox/Runtime/testcase/tstMemAutoPtr.cpp

    r28800 r31157  
    55
    66/*
    7  * Copyright (C) 2008 Oracle Corporation
     7 * Copyright (C) 2008-2010 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    114114
    115115
    116 void *tstMemAutoPtrAllocatorNoZero(void *pvOld, size_t cbNew)
    117 {
    118     void *pvNew = RTMemRealloc(pvOld, cbNew);
     116void *tstMemAutoPtrAllocatorNoZero(void *pvOld, size_t cbNew, const char *pszTag)
     117{
     118    void *pvNew = RTMemReallocTag(pvOld, cbNew, pszTag);
    119119    if (pvNew)
    120120        memset(pvNew, 0xfe, cbNew);
  • trunk/src/VBox/Runtime/testcase/tstRTMemEf.cpp

    r28800 r31157  
    4747     * the word after the allocated block and the word before. One of them
    4848     * will crash no matter whether the fence is at the bottom or on top. */
    49     int32_t *p = (int32_t *)RTMemEfAllocNP(sizeof(int32_t));
     49    int32_t *p = (int32_t *)RTMemEfAllocNP(sizeof(int32_t), RTMEM_TAG);
    5050    RTPrintf("tstRTMemAllocEfAccess: allocated int32_t at %#p\n", p);
    5151    RTPrintf("tstRTMemAllocEfAccess: triggering buffer overrun...\n");
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette