VirtualBox

忽略:
時間撮記:
2010-7-28 上午03:15:35 (14 年 以前)
作者:
vboxsync
訊息:

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

檔案:
修改 1 筆資料

圖例:

未更動
新增
刪除
  • 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)
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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