VirtualBox

Ignore:
Timestamp:
Apr 14, 2010 12:20:39 PM (15 years ago)
Author:
vboxsync
Message:

iprt,Config.kmk: Make sure the RTMemAllocVar* alignment gets poisoned by the electric fence. Some interface refactoring.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/alloc/alloc.cpp

    r28271 r28298  
    3939#include <iprt/string.h>
    4040
    41 #ifdef RTMEM_WRAP_TO_EF_APIS
    42 # undef RTMemAllocVar
    43 # undef RTMemAllocZVar
    44 # undef RTMemDup
    45 # undef RTMemDupEx
    46 #endif
     41#undef RTMemDup
     42#undef RTMemDupEx
    4743
    48 
    49 
    50 /**
    51  * Wrapper around RTMemAlloc for automatically aligning variable sized
    52  * allocations so that the various electric fence heaps works correctly.
    53  *
    54  * @returns See RTMemAlloc.
    55  * @param   cbUnaligned         The unaligned size.
    56  */
    57 RTDECL(void *) RTMemAllocVar(size_t cbUnaligned)
    58 {
    59     size_t cbAligned;
    60     if (cbUnaligned >= 16)
    61         cbAligned = RT_ALIGN_Z(cbUnaligned, 16);
    62     else
    63         cbAligned = RT_ALIGN_Z(cbUnaligned, sizeof(void *));
    64     return RTMemAlloc(cbAligned);
    65 }
    66 
    67 
    68 /**
    69  * Wrapper around RTMemAllocZ for automatically aligning variable sized
    70  * allocations so that the various electric fence heaps works correctly.
    71  *
    72  * @returns See RTMemAllocZ.
    73  * @param   cbUnaligned         The unaligned size.
    74  */
    75 RTDECL(void *) RTMemAllocZVar(size_t cbUnaligned)
    76 {
    77     size_t cbAligned;
    78     if (cbUnaligned >= 16)
    79         cbAligned = RT_ALIGN_Z(cbUnaligned, 16);
    80     else
    81         cbAligned = RT_ALIGN_Z(cbUnaligned, sizeof(void *));
    82     return RTMemAllocZ(cbAligned);
    83 }
    8444
    8545
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