Commit b1e8c6fb by alokp@chromium.org

Getting ready to fix compile-errors on mac. This CL only contains cosmetic…

Getting ready to fix compile-errors on mac. This CL only contains cosmetic changes. Removed SGI_STL blocks. Removed tabs and fixed formatting. Review URL: http://codereview.appspot.com/1138043 git-svn-id: https://angleproject.googlecode.com/svn/trunk@272 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 4071e661
...@@ -152,11 +152,11 @@ const unsigned char TAllocation::guardBlockBeginVal = 0xfb; ...@@ -152,11 +152,11 @@ const unsigned char TAllocation::guardBlockBeginVal = 0xfb;
const unsigned char TAllocation::guardBlockEndVal = 0xfe; const unsigned char TAllocation::guardBlockEndVal = 0xfe;
const unsigned char TAllocation::userDataFill = 0xcd; const unsigned char TAllocation::userDataFill = 0xcd;
# ifdef GUARD_BLOCKS #ifdef GUARD_BLOCKS
const size_t TAllocation::guardBlockSize = 16; const size_t TAllocation::guardBlockSize = 16;
# else #else
const size_t TAllocation::guardBlockSize = 0; const size_t TAllocation::guardBlockSize = 0;
# endif #endif
// //
// Check a single guard block for damage // Check a single guard block for damage
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#define _POOLALLOC_INCLUDED_ #define _POOLALLOC_INCLUDED_
#ifdef _DEBUG #ifdef _DEBUG
# define GUARD_BLOCKS // define to enable guard block sanity checking #define GUARD_BLOCKS // define to enable guard block sanity checking
#endif #endif
// //
...@@ -48,11 +48,11 @@ public: ...@@ -48,11 +48,11 @@ public:
// This would be cleaner with if (guardBlockSize)..., but that // This would be cleaner with if (guardBlockSize)..., but that
// makes the compiler print warnings about 0 length memsets, // makes the compiler print warnings about 0 length memsets,
// even with the if() protecting them. // even with the if() protecting them.
# ifdef GUARD_BLOCKS #ifdef GUARD_BLOCKS
memset(preGuard(), guardBlockBeginVal, guardBlockSize); memset(preGuard(), guardBlockBeginVal, guardBlockSize);
memset(data(), userDataFill, size); memset(data(), userDataFill, size);
memset(postGuard(), guardBlockEndVal, guardBlockSize); memset(postGuard(), guardBlockEndVal, guardBlockSize);
# endif #endif
} }
void check() const { void check() const {
...@@ -91,11 +91,11 @@ private: ...@@ -91,11 +91,11 @@ private:
const static unsigned char userDataFill; const static unsigned char userDataFill;
const static size_t guardBlockSize; const static size_t guardBlockSize;
# ifdef GUARD_BLOCKS #ifdef GUARD_BLOCKS
inline static size_t headerSize() { return sizeof(TAllocation); } inline static size_t headerSize() { return sizeof(TAllocation); }
# else #else
inline static size_t headerSize() { return 0; } inline static size_t headerSize() { return 0; }
# endif #endif
}; };
// //
...@@ -159,7 +159,8 @@ protected: ...@@ -159,7 +159,8 @@ protected:
#ifdef GUARD_BLOCKS #ifdef GUARD_BLOCKS
lastAllocation(0), lastAllocation(0),
#endif #endif
nextPage(nextPage), pageCount(pageCount) { } nextPage(nextPage),
pageCount(pageCount) { }
~tHeader() { ~tHeader() {
#ifdef GUARD_BLOCKS #ifdef GUARD_BLOCKS
...@@ -183,11 +184,10 @@ protected: ...@@ -183,11 +184,10 @@ protected:
// Track allocations if and only if we're using guard blocks // Track allocations if and only if we're using guard blocks
void* initializeAllocation(tHeader* block, unsigned char* memory, size_t numBytes) { void* initializeAllocation(tHeader* block, unsigned char* memory, size_t numBytes) {
# ifdef GUARD_BLOCKS #ifdef GUARD_BLOCKS
new(memory) TAllocation(numBytes, memory, block->lastAllocation); new(memory) TAllocation(numBytes, memory, block->lastAllocation);
block->lastAllocation = reinterpret_cast<TAllocation*>(memory); block->lastAllocation = reinterpret_cast<TAllocation*>(memory);
# endif #endif
// This is optimized entirely away if GUARD_BLOCKS is not defined. // This is optimized entirely away if GUARD_BLOCKS is not defined.
return TAllocation::offsetAllocation(memory); return TAllocation::offsetAllocation(memory);
} }
...@@ -242,11 +242,12 @@ class pool_allocator { ...@@ -242,11 +242,12 @@ class pool_allocator {
public: public:
typedef size_t size_type; typedef size_t size_type;
typedef ptrdiff_t difference_type; typedef ptrdiff_t difference_type;
typedef T *pointer; typedef T* pointer;
typedef const T *const_pointer; typedef const T* const_pointer;
typedef T& reference; typedef T& reference;
typedef const T& const_reference; typedef const T& const_reference;
typedef T value_type; typedef T value_type;
template<class Other> template<class Other>
struct rebind { struct rebind {
typedef pool_allocator<Other> other; typedef pool_allocator<Other> other;
...@@ -254,48 +255,26 @@ public: ...@@ -254,48 +255,26 @@ public:
pointer address(reference x) const { return &x; } pointer address(reference x) const { return &x; }
const_pointer address(const_reference x) const { return &x; } const_pointer address(const_reference x) const { return &x; }
#ifdef USING_SGI_STL
pool_allocator() { }
#else
pool_allocator() : allocator(GlobalPoolAllocator) { } pool_allocator() : allocator(GlobalPoolAllocator) { }
pool_allocator(TPoolAllocator& a) : allocator(a) { } pool_allocator(TPoolAllocator& a) : allocator(a) { }
pool_allocator(const pool_allocator<T>& p) : allocator(p.allocator) { } pool_allocator(const pool_allocator<T>& p) : allocator(p.allocator) { }
#endif
#if defined(_MSC_VER) && _MSC_VER >= 1300
template<class Other> template<class Other>
#ifdef USING_SGI_STL
pool_allocator(const pool_allocator<Other>& p) /*: allocator(p.getAllocator())*/ { }
#else
pool_allocator(const pool_allocator<Other>& p) : allocator(p.getAllocator()) { } pool_allocator(const pool_allocator<Other>& p) : allocator(p.getAllocator()) { }
#endif
#endif
#ifndef _WIN32
template<class Other>
pool_allocator(const pool_allocator<Other>& p) : allocator(p.getAllocator()) { }
#endif
#ifdef USING_SGI_STL
static pointer allocate(size_type n) {
return reinterpret_cast<pointer>(getAllocator().allocate(n)); }
pointer allocate(size_type n, const void*) {
return reinterpret_cast<pointer>(getAllocator().allocate(n)); }
static void deallocate(void*, size_type) { }
static void deallocate(pointer, size_type) { }
#else
pointer allocate(size_type n) { pointer allocate(size_type n) {
return reinterpret_cast<pointer>(getAllocator().allocate(n * sizeof(T))); } return reinterpret_cast<pointer>(getAllocator().allocate(n * sizeof(T)));
}
pointer allocate(size_type n, const void*) { pointer allocate(size_type n, const void*) {
return reinterpret_cast<pointer>(getAllocator().allocate(n * sizeof(T))); } return reinterpret_cast<pointer>(getAllocator().allocate(n * sizeof(T)));
}
void deallocate(void*, size_type) { } void deallocate(void*, size_type) { }
void deallocate(pointer, size_type) { } void deallocate(pointer, size_type) { }
#endif
pointer _Charalloc(size_t n) { pointer _Charalloc(size_t n) {
return reinterpret_cast<pointer>(getAllocator().allocate(n)); } return reinterpret_cast<pointer>(getAllocator().allocate(n));
}
void construct(pointer p, const T& val) { new ((void *)p) T(val); } void construct(pointer p, const T& val) { new ((void *)p) T(val); }
void destroy(pointer p) { p->T::~T(); } void destroy(pointer p) { p->T::~T(); }
...@@ -306,16 +285,11 @@ public: ...@@ -306,16 +285,11 @@ public:
size_type max_size() const { return static_cast<size_type>(-1) / sizeof(T); } size_type max_size() const { return static_cast<size_type>(-1) / sizeof(T); }
size_type max_size(int size) const { return static_cast<size_type>(-1) / size; } size_type max_size(int size) const { return static_cast<size_type>(-1) / size; }
#ifdef USING_SGI_STL
//void setAllocator(TPoolAllocator* a) { allocator = a; }
static TPoolAllocator& getAllocator() { return GlobalPoolAllocator; }
#else
void setAllocator(TPoolAllocator* a) { allocator = *a; } void setAllocator(TPoolAllocator* a) { allocator = *a; }
TPoolAllocator& getAllocator() const { return allocator; } TPoolAllocator& getAllocator() const { return allocator; }
protected: protected:
TPoolAllocator& allocator; TPoolAllocator& allocator;
#endif
}; };
#endif // _POOLALLOC_INCLUDED_ #endif // _POOLALLOC_INCLUDED_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment