diff --git a/external/3rd/library/platform/utils/Base/Statistics.h b/external/3rd/library/platform/utils/Base/Statistics.h index b39f755f..18e0579e 100644 --- a/external/3rd/library/platform/utils/Base/Statistics.h +++ b/external/3rd/library/platform/utils/Base/Statistics.h @@ -36,7 +36,7 @@ namespace Base if (!mLastSampleTime) mLastSampleTime = time(NULL); - if (!mSampleFrequency || mLastSampleTime + mSampleFrequency < (uintptr_t)time(NULL)) + if (!mSampleFrequency || mLastSampleTime + mSampleFrequency < (unsigned)time(NULL)) { mSampleTotal++; mAggregateTotal += value; diff --git a/external/3rd/library/platform/utils/Base/win32/BlockAllocator.cpp b/external/3rd/library/platform/utils/Base/win32/BlockAllocator.cpp index 2ed57637..029946b4 100644 --- a/external/3rd/library/platform/utils/Base/win32/BlockAllocator.cpp +++ b/external/3rd/library/platform/utils/Base/win32/BlockAllocator.cpp @@ -79,7 +79,7 @@ namespace Base if(m_blocks[accum] == 0) { // remove the pre allocated block from the linked list - handle = (uintptr_t *)calloc(((1 << accum) / 4) + 2, sizeof(uintptr_t)); + handle = (uintptr_t *)calloc(((1 << accum) / 4) + 2, sizeof(unsigned)); handle[1] = accum; handle[0] = 0; } @@ -94,7 +94,7 @@ namespace Base return(handle + 2); } - void BlockAllocator::returnBlock(uintptr_t *handle) + void BlockAllocator::returnBlock(unsigned *handle) { // C++ allows for safe deletion of a NULL pointer if(handle) diff --git a/external/3rd/library/soePlatform/CSAssist/utils/Base/BlockAllocator.h b/external/3rd/library/soePlatform/CSAssist/utils/Base/BlockAllocator.h index bbfbf273..5daf69da 100644 --- a/external/3rd/library/soePlatform/CSAssist/utils/Base/BlockAllocator.h +++ b/external/3rd/library/soePlatform/CSAssist/utils/Base/BlockAllocator.h @@ -20,7 +20,7 @@ namespace Base void returnBlock(unsigned *handle); private: - uintptr_t *m_blocks[31]; + unsigned *m_blocks[31]; }; }; #ifdef EXTERNAL_DISTRO diff --git a/external/3rd/library/soePlatform/CSAssist/utils/Base/Statistics.h b/external/3rd/library/soePlatform/CSAssist/utils/Base/Statistics.h index b39f755f..18e0579e 100644 --- a/external/3rd/library/soePlatform/CSAssist/utils/Base/Statistics.h +++ b/external/3rd/library/soePlatform/CSAssist/utils/Base/Statistics.h @@ -36,7 +36,7 @@ namespace Base if (!mLastSampleTime) mLastSampleTime = time(NULL); - if (!mSampleFrequency || mLastSampleTime + mSampleFrequency < (uintptr_t)time(NULL)) + if (!mSampleFrequency || mLastSampleTime + mSampleFrequency < (unsigned)time(NULL)) { mSampleTotal++; mAggregateTotal += value; diff --git a/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/BlockAllocator.cpp b/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/BlockAllocator.cpp index fe891286..9fa8b645 100644 --- a/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/BlockAllocator.cpp +++ b/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/BlockAllocator.cpp @@ -1,111 +1,111 @@ #include "../BlockAllocator.h" #ifdef EXTERNAL_DISTRO -namespace NAMESPACE +namespace NAMESPACE { #endif - namespace Base +namespace Base +{ + + BlockAllocator::BlockAllocator() { - - BlockAllocator::BlockAllocator() + for(unsigned i = 0; i < 31; i++) { - for (unsigned i = 0; i < 31; i++) + m_blocks[i] = NULL; + } + } + + BlockAllocator::~BlockAllocator() + { + // free all allocated memory blocks + for(unsigned i = 0; i < 31; i++) + { + while(m_blocks[i] != NULL) { - m_blocks[i] = NULL; + unsigned *tmp = m_blocks[i]; + m_blocks[i] = (unsigned *)*m_blocks[i]; + free(tmp); } } + } - BlockAllocator::~BlockAllocator() +// Allocate a block that is the next power of two greater than the # of bytes passed. +// 33 bytes yields a 64 byte block of memory and so forth. + + void *BlockAllocator::getBlock(unsigned bytes) + { + unsigned accum = 16, bits = 16; + unsigned *handle = NULL; + + // Perform a binary search looking for the highest bit. + + while(bits != 0) { - // free all allocated memory blocks - for (unsigned i = 0; i < 31; i++) + // If bytes is less than the bit we're testing for, subtract half + // from the bit value and repeat + if(bytes < (unsigned)(1 << accum)) { - while (m_blocks[i] != NULL) - { - uintptr_t *tmp = m_blocks[i]; - m_blocks[i] = (uintptr_t *)*m_blocks[i]; - free(tmp); - } + bits /= 2; + accum -= bits; } - } - - // Allocate a block that is the next power of two greater than the # of bytes passed. - // 33 bytes yields a 64 byte block of memory and so forth. - - void *BlockAllocator::getBlock(unsigned bytes) - { - unsigned accum = 16, bits = 16; - uintptr_t *handle = NULL; - - // Perform a binary search looking for the highest bit. - - while (bits != 0) + // If bytes is greater than the bit we're testing for, add half + // from the but value and repeat + else if(bytes > (unsigned)(1 << accum)) { - // If bytes is less than the bit we're testing for, subtract half - // from the bit value and repeat - if (bytes < (unsigned)(1 << accum)) - { - bits /= 2; - accum -= bits; - } - // If bytes is greater than the bit we're testing for, add half - // from the but value and repeat - else if (bytes >(unsigned)(1 << accum)) - { - bits /= 2; - accum += bits; - } - // Got lucky and hit the value dead on - else - { - break; - } - } - // At this point accum contains the most significant bit index, increment - accum++; - if (accum < 2) - { - accum = 2; - } - - // Note that when memory is actually allocated, 8 extra bytes will be allocated.at the front - // The first integer is the address of the next block of memory when the block is in the allocator - // The second integer is the bit length of the block - // Memory is allocated on 4 byte boundaries to sidestep byte alignment problems - - - // Check if the allocator already has a block of that size - if (m_blocks[accum] == 0) - { - // remove the pre allocated block from the linked list - handle = (uintptr_t *)calloc(((1 << accum) / 4) + 2, sizeof(uintptr_t)); - handle[1] = accum; - handle[0] = 0; + bits /= 2; + accum += bits; } + // Got lucky and hit the value dead on else { - // Allocate a new block - handle = m_blocks[accum]; - m_blocks[accum] = (uintptr_t *)handle[0]; - handle[0] = 0; + break; } - // return a pointer that skips over the header used for the allocator's purposes - return(handle + 2); } - - void BlockAllocator::returnBlock(uintptr_t *handle) + // At this point accum contains the most significant bit index, increment + accum++; + if(accum < 2) { - // C++ allows for safe deletion of a NULL pointer - if (handle) - { - // Update the allocator linked list, insert this entry at the head - *(handle - 2) = (uintptr_t)m_blocks[*(handle - 1)]; - // Add this entry to the proper linked list node - m_blocks[*(handle - 1)] = (handle - 2); - } + accum = 2; } - }; + + // Note that when memory is actually allocated, 8 extra bytes will be allocated.at the front + // The first integer is the address of the next block of memory when the block is in the allocator + // The second integer is the bit length of the block + // Memory is allocated on 4 byte boundaries to sidestep byte alignment problems + + + // Check if the allocator already has a block of that size + if(m_blocks[accum] == 0) + { + // remove the pre allocated block from the linked list + handle = (unsigned *)calloc(((1 << accum) / 4) + 2, sizeof(unsigned)); + handle[1] = accum; + handle[0] = 0; + } + else + { + // Allocate a new block + handle = m_blocks[accum]; + m_blocks[accum] = (unsigned *)handle[0]; + handle[0] = 0; + } + // return a pointer that skips over the header used for the allocator's purposes + return(handle + 2); + } + + void BlockAllocator::returnBlock(unsigned *handle) + { + // C++ allows for safe deletion of a NULL pointer + if(handle) + { + // Update the allocator linked list, insert this entry at the head + *(handle - 2) = (unsigned)m_blocks[*(handle - 1)]; + // Add this entry to the proper linked list node + m_blocks[*(handle - 1)] = (handle - 2); + } + } +}; #ifdef EXTERNAL_DISTRO }; #endif diff --git a/external/3rd/library/soePlatform/ChatAPI/utils/Base/BlockAllocator.h b/external/3rd/library/soePlatform/ChatAPI/utils/Base/BlockAllocator.h index bbfbf273..5daf69da 100644 --- a/external/3rd/library/soePlatform/ChatAPI/utils/Base/BlockAllocator.h +++ b/external/3rd/library/soePlatform/ChatAPI/utils/Base/BlockAllocator.h @@ -20,7 +20,7 @@ namespace Base void returnBlock(unsigned *handle); private: - uintptr_t *m_blocks[31]; + unsigned *m_blocks[31]; }; }; #ifdef EXTERNAL_DISTRO diff --git a/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/BlockAllocator.cpp b/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/BlockAllocator.cpp index fe891286..9fa8b645 100644 --- a/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/BlockAllocator.cpp +++ b/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/BlockAllocator.cpp @@ -1,111 +1,111 @@ #include "../BlockAllocator.h" #ifdef EXTERNAL_DISTRO -namespace NAMESPACE +namespace NAMESPACE { #endif - namespace Base +namespace Base +{ + + BlockAllocator::BlockAllocator() { - - BlockAllocator::BlockAllocator() + for(unsigned i = 0; i < 31; i++) { - for (unsigned i = 0; i < 31; i++) + m_blocks[i] = NULL; + } + } + + BlockAllocator::~BlockAllocator() + { + // free all allocated memory blocks + for(unsigned i = 0; i < 31; i++) + { + while(m_blocks[i] != NULL) { - m_blocks[i] = NULL; + unsigned *tmp = m_blocks[i]; + m_blocks[i] = (unsigned *)*m_blocks[i]; + free(tmp); } } + } - BlockAllocator::~BlockAllocator() +// Allocate a block that is the next power of two greater than the # of bytes passed. +// 33 bytes yields a 64 byte block of memory and so forth. + + void *BlockAllocator::getBlock(unsigned bytes) + { + unsigned accum = 16, bits = 16; + unsigned *handle = NULL; + + // Perform a binary search looking for the highest bit. + + while(bits != 0) { - // free all allocated memory blocks - for (unsigned i = 0; i < 31; i++) + // If bytes is less than the bit we're testing for, subtract half + // from the bit value and repeat + if(bytes < (unsigned)(1 << accum)) { - while (m_blocks[i] != NULL) - { - uintptr_t *tmp = m_blocks[i]; - m_blocks[i] = (uintptr_t *)*m_blocks[i]; - free(tmp); - } + bits /= 2; + accum -= bits; } - } - - // Allocate a block that is the next power of two greater than the # of bytes passed. - // 33 bytes yields a 64 byte block of memory and so forth. - - void *BlockAllocator::getBlock(unsigned bytes) - { - unsigned accum = 16, bits = 16; - uintptr_t *handle = NULL; - - // Perform a binary search looking for the highest bit. - - while (bits != 0) + // If bytes is greater than the bit we're testing for, add half + // from the but value and repeat + else if(bytes > (unsigned)(1 << accum)) { - // If bytes is less than the bit we're testing for, subtract half - // from the bit value and repeat - if (bytes < (unsigned)(1 << accum)) - { - bits /= 2; - accum -= bits; - } - // If bytes is greater than the bit we're testing for, add half - // from the but value and repeat - else if (bytes >(unsigned)(1 << accum)) - { - bits /= 2; - accum += bits; - } - // Got lucky and hit the value dead on - else - { - break; - } - } - // At this point accum contains the most significant bit index, increment - accum++; - if (accum < 2) - { - accum = 2; - } - - // Note that when memory is actually allocated, 8 extra bytes will be allocated.at the front - // The first integer is the address of the next block of memory when the block is in the allocator - // The second integer is the bit length of the block - // Memory is allocated on 4 byte boundaries to sidestep byte alignment problems - - - // Check if the allocator already has a block of that size - if (m_blocks[accum] == 0) - { - // remove the pre allocated block from the linked list - handle = (uintptr_t *)calloc(((1 << accum) / 4) + 2, sizeof(uintptr_t)); - handle[1] = accum; - handle[0] = 0; + bits /= 2; + accum += bits; } + // Got lucky and hit the value dead on else { - // Allocate a new block - handle = m_blocks[accum]; - m_blocks[accum] = (uintptr_t *)handle[0]; - handle[0] = 0; + break; } - // return a pointer that skips over the header used for the allocator's purposes - return(handle + 2); } - - void BlockAllocator::returnBlock(uintptr_t *handle) + // At this point accum contains the most significant bit index, increment + accum++; + if(accum < 2) { - // C++ allows for safe deletion of a NULL pointer - if (handle) - { - // Update the allocator linked list, insert this entry at the head - *(handle - 2) = (uintptr_t)m_blocks[*(handle - 1)]; - // Add this entry to the proper linked list node - m_blocks[*(handle - 1)] = (handle - 2); - } + accum = 2; } - }; + + // Note that when memory is actually allocated, 8 extra bytes will be allocated.at the front + // The first integer is the address of the next block of memory when the block is in the allocator + // The second integer is the bit length of the block + // Memory is allocated on 4 byte boundaries to sidestep byte alignment problems + + + // Check if the allocator already has a block of that size + if(m_blocks[accum] == 0) + { + // remove the pre allocated block from the linked list + handle = (unsigned *)calloc(((1 << accum) / 4) + 2, sizeof(unsigned)); + handle[1] = accum; + handle[0] = 0; + } + else + { + // Allocate a new block + handle = m_blocks[accum]; + m_blocks[accum] = (unsigned *)handle[0]; + handle[0] = 0; + } + // return a pointer that skips over the header used for the allocator's purposes + return(handle + 2); + } + + void BlockAllocator::returnBlock(unsigned *handle) + { + // C++ allows for safe deletion of a NULL pointer + if(handle) + { + // Update the allocator linked list, insert this entry at the head + *(handle - 2) = (unsigned)m_blocks[*(handle - 1)]; + // Add this entry to the proper linked list node + m_blocks[*(handle - 1)] = (handle - 2); + } + } +}; #ifdef EXTERNAL_DISTRO }; #endif