VirtualBox

忽略:
時間撮記:
2010-8-31 上午10:16:05 (14 年 以前)
作者:
vboxsync
訊息:

iprt/memtracker: hacking in progress.

檔案:
修改 1 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Runtime/r3/alloc.cpp

    r31274 r32125  
    4242#include <iprt/asm.h>
    4343#include <iprt/assert.h>
     44#ifdef RTMEMALLOC_USE_TRACKER
     45# include <iprt/memtracker.h>
     46#endif
    4447#include <iprt/param.h>
    4548#include <iprt/string.h>
     
    9598
    9699    AssertMsg(cb, ("Allocating ZERO bytes is really not a good idea! Good luck with the next assertion!\n"));
     100# ifdef RTMEMALLOC_USE_TRACKER
     101    void *pv = RTMemTrackerHdrAlloc(malloc(cb + sizeof(RTMEMTRACKERHDR)), cb, pszTag, RTMEMTRACKERMETHOD_ALLOC);
     102# else
    97103    void *pv = malloc(cb);
     104# endif
    98105    AssertMsg(pv, ("malloc(%#zx) failed!!!\n", cb));
    99106    AssertMsg(   cb < RTMEM_ALIGNMENT
     
    115122    AssertMsg(cb, ("Allocating ZERO bytes is really not a good idea! Good luck with the next assertion!\n"));
    116123
     124# ifdef RTMEMALLOC_USE_TRACKER
     125    void *pv = RTMemTrackerHdrAlloc(calloc(1, cb + sizeof(RTMEMTRACKERHDR)), cb, pszTag, RTMEMTRACKERMETHOD_ALLOCZ);
     126#else
    117127    void *pv = calloc(1, cb);
     128#endif
    118129    AssertMsg(pv, ("calloc(1,%#zx) failed!!!\n", cb));
    119130    AssertMsg(   cb < RTMEM_ALIGNMENT
     
    165176#else /* !RTALLOC_USE_EFENCE */
    166177
     178# ifdef RTALLOC_USE_TRACKER
     179    void *pv;
     180    if (!pvOld)
     181    {
     182        if (cbNew)
     183            pv = RTMemTrackerHdrAlloc(realloc(pvOld, cbNew + sizeof(RTMEMTRACKERHDR)), cbNew,
     184                                      pszTag, RTMEMTRACKERMETHOD_REALLOC);
     185        else
     186            pv = NULL;
     187    }
     188    else
     189    {
     190        RTMemTrackerHdrReallocPrep(pvOld, 0, pszTag, RTMEMTRACKERMETHOD_REALLOC);
     191        pv = RTMemTrackerHdrRealloc(realloc(pvOld, cbNew + sizeof(RTMEMTRACKERHDR)), cbNew, pvOld,
     192                                    pszTag, RTMEMTRACKERMETHOD_REALLOC);
     193    }
     194# else
    167195    void *pv = realloc(pvOld, cbNew);
     196# endif
    168197    AssertMsg(pv || !cbNew, ("realloc(%p, %#zx) failed!!!\n", pvOld, cbNew));
    169198    AssertMsg(   cbNew < RTMEM_ALIGNMENT
     
    182211        rtR3MemFree("Free", RTMEMTYPE_RTMEMFREE, pv, ASMReturnAddress(), NULL, 0, NULL);
    183212#else
     213# ifdef RTALLOC_USE_TRACKER
     214        pv = RTMemTrackerHdrFree(pv, 0, NULL, RTMEMTRACKERMETHOD_FREE);
     215# endif
    184216        free(pv);
    185217#endif
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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