VirtualBox

Changeset 31157 in vbox for trunk/src/VBox/Runtime/r3


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

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

Location:
trunk/src/VBox/Runtime/r3
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • 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;
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