VirtualBox

忽略:
時間撮記:
2010-4-13 下午07:29:42 (15 年 以前)
作者:
vboxsync
訊息:

IPRT: Some efence adjustments, adding RTMemAllocVar and RTMemAllocZVar for dealing with struct + string style allocations.

檔案:
修改 1 筆資料

圖例:

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

    r24958 r28271  
    2828 * additional information or have any questions.
    2929 */
     30
     31
     32/*******************************************************************************
     33*   Defined Constants And Macros                                               *
     34*******************************************************************************/
     35#ifdef RTMEM_WRAP_TO_EF_APIS
     36# undef RTMEM_WRAP_TO_EF_APIS
     37# define RTALLOC_USE_EFENCE 1
     38#endif
    3039
    3140
     
    103112    void *pv = malloc(cb);
    104113    AssertMsg(pv, ("malloc(%#zx) failed!!!\n", cb));
    105 #ifdef RT_OS_OS2 /* temporary workaround until libc062. */
    106     AssertMsg(   cb < 32
    107               || !((uintptr_t)pv & (RTMEM_ALIGNMENT - 1)), ("pv=%p RTMEM_ALIGNMENT=%#x\n", pv, RTMEM_ALIGNMENT));
    108 #else
    109114    AssertMsg(   cb < RTMEM_ALIGNMENT
    110               || !((uintptr_t)pv & (RTMEM_ALIGNMENT - 1)), ("pv=%p RTMEM_ALIGNMENT=%#x\n", pv, RTMEM_ALIGNMENT));
    111 #endif
     115              || !((uintptr_t)pv & (RTMEM_ALIGNMENT - 1))
     116              || ( (cb & RTMEM_ALIGNMENT) + ((uintptr_t)pv & RTMEM_ALIGNMENT)) == RTMEM_ALIGNMENT
     117              , ("pv=%p RTMEM_ALIGNMENT=%#x\n", pv, RTMEM_ALIGNMENT));
    112118#endif /* !RTALLOC_USE_EFENCE */
    113119    return pv;
     
    137143    void *pv = calloc(1, cb);
    138144    AssertMsg(pv, ("calloc(1,%#zx) failed!!!\n", cb));
    139 #ifdef RT_OS_OS2 /* temporary workaround until libc062. */
    140     AssertMsg(   cb < 32
    141               || !((uintptr_t)pv & (RTMEM_ALIGNMENT - 1)), ("pv=%p RTMEM_ALIGNMENT=%#x\n", pv, RTMEM_ALIGNMENT));
    142 #else
    143145    AssertMsg(   cb < RTMEM_ALIGNMENT
    144               || !((uintptr_t)pv & (RTMEM_ALIGNMENT - 1)), ("pv=%p RTMEM_ALIGNMENT=%#x\n", pv, RTMEM_ALIGNMENT));
    145 #endif
     146              || !((uintptr_t)pv & (RTMEM_ALIGNMENT - 1))
     147              || ( (cb & RTMEM_ALIGNMENT) + ((uintptr_t)pv & RTMEM_ALIGNMENT)) == RTMEM_ALIGNMENT
     148              , ("pv=%p RTMEM_ALIGNMENT=%#x\n", pv, RTMEM_ALIGNMENT));
    146149#endif /* !RTALLOC_USE_EFENCE */
    147150    return pv;
     
    166169    void *pv = realloc(pvOld, cbNew);
    167170    AssertMsg(pv && cbNew, ("realloc(%p, %#zx) failed!!!\n", pvOld, cbNew));
    168 #ifdef RT_OS_OS2 /* temporary workaround until libc062. */
    169     AssertMsg(   cbNew < 32
    170               || !((uintptr_t)pv & (RTMEM_ALIGNMENT - 1)), ("pv=%p RTMEM_ALIGNMENT=%#x\n", pv, RTMEM_ALIGNMENT));
    171 #else
    172171    AssertMsg(   cbNew < RTMEM_ALIGNMENT
    173               || !((uintptr_t)pv & (RTMEM_ALIGNMENT - 1)), ("pv=%p RTMEM_ALIGNMENT=%#x\n", pv, RTMEM_ALIGNMENT));
    174 #endif
     172              || !((uintptr_t)pv & (RTMEM_ALIGNMENT - 1))
     173              || ( (cbNew & RTMEM_ALIGNMENT) + ((uintptr_t)pv & RTMEM_ALIGNMENT)) == RTMEM_ALIGNMENT
     174              , ("pv=%p RTMEM_ALIGNMENT=%#x\n", pv, RTMEM_ALIGNMENT));
    175175#endif  /* !RTALLOC_USE_EFENCE */
    176176    return pv;
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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