Ignore:
Timestamp:
May 19, 2013, 9:20:51 AM (6 years ago)
Author:
cameron
Message:

Fixes for icXML 0.9

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icXML/icXML-devel/src/icxercesc/util/XMemory.cpp

    r2721 r3157  
    2323XERCES_CPP_NAMESPACE_BEGIN
    2424
    25 enum
    26 {
    27         kDefaultAlignment =
    28         #ifdef XML_PLATFORM_NEW_BLOCK_ALIGNMENT
    29                 XML_PLATFORM_NEW_BLOCK_ALIGNMENT
    30         #else
    31                 ((sizeof(void*) >= sizeof(double)) ? sizeof(void*) : sizeof(double))
    32         #endif
    33         , headerSize =
    34                 (sizeof(MemoryManager*) % kDefaultAlignment) == 0 ?
    35                         sizeof(MemoryManager*) :
    36                         sizeof(MemoryManager*) + kDefaultAlignment - (sizeof(MemoryManager*) % kDefaultAlignment)
    37 };
     25#define HEADER_SIZE (XMLPlatformUtils::alignPointerForNewBlockAllocation(sizeof(MemoryManager*)))
    3826
    3927void* XMemory::operator new(size_t size)
    4028{
    41         void* const block = XMLPlatformUtils::fgMemoryManager->allocate(headerSize + size);
    42         *(MemoryManager**)block = XMLPlatformUtils::fgMemoryManager;
    43 
    44         return (char*)block + headerSize;
     29    void* const block = XMLPlatformUtils::fgMemoryManager->allocate(HEADER_SIZE + size);
     30    *(MemoryManager**)block = XMLPlatformUtils::fgMemoryManager;
     31    return (char*)block + HEADER_SIZE;
    4532}
    4633
     
    6148void* XMemory::operator new(size_t size, MemoryManager* manager)
    6249{
    63         void * const block = manager->allocate(headerSize + size);
    64         *(MemoryManager**)block = manager;
    65         return (char*)block + headerSize;
     50    void * const block = manager->allocate(HEADER_SIZE + size);
     51    *(MemoryManager**)block = manager;
     52    return (char*)block + HEADER_SIZE;
    6653}
    6754
     
    7562        if (p != 0)
    7663        {
    77                 void* const block = (char*)p - headerSize;
     64        void* const block = (char*)p - HEADER_SIZE;
    7865                MemoryManager* const manager = *(MemoryManager**)block;
    7966                manager->deallocate(block);
     
    8976        if (p != 0)
    9077        {
    91                 void* const block = (char*)p - headerSize;
     78        void* const block = (char*)p - HEADER_SIZE;
    9279                /***
    9380                 * assert(*(MemoryManager**)block == manager);
     
    10996#endif
    11097
    111 #undef XML_PLATFORM_DEFAULT_NEW_BLOCK_ALIGNMENT
     98#undef HEADER_SIZE
    11299
    113100XERCES_CPP_NAMESPACE_END
Note: See TracChangeset for help on using the changeset viewer.