diff --git a/panda/src/putil/test_uniqueIdAllocator.cxx b/panda/src/putil/test_uniqueIdAllocator.cxx index 9a50b7b40c..d325f814d4 100644 --- a/panda/src/putil/test_uniqueIdAllocator.cxx +++ b/panda/src/putil/test_uniqueIdAllocator.cxx @@ -1,47 +1,47 @@ - - -#include "stdafx.h" - -#include -#include -#include -using namespace std; - -#include "uniqueIdAllocator.h" - - -int _tmain(int argc, _TCHAR* argv[]) { - cout <<"UniqueIdAllocator Test"< +#include +#include +using namespace std; + +#include "uniqueIdAllocator.h" + + +int _tmain(int argc, _TCHAR* argv[]) { + cout <<"UniqueIdAllocator Test"< 0. - _table=new U32[_size]; - assert(_table); // This should be redundant if new throws an exception. - for (U32 i=0; i<_size; ++i) { - _table[i]=i+1; - } - _table[_size-1]=-1; - _next_free=0; - _last_free=_size-1; - _free=_size; -} - -//////////////////////////////////////////////////////////////////// -// Function: -// Access: -// Description: -//////////////////////////////////////////////////////////////////// -UniqueIdAllocator:: -~UniqueIdAllocator() { - //cout<<"UniqueIdAllocator::~UniqueIdAllocator()"<>2)) { - // ...under 1/4 of the ids are free. - cerr<<"UniqueIdAllocator Error: 75% of ids allocated."<=_min); // Attempt to free out-of-range id. - assert(index<=_max); // Attempt to free out-of-range id. - index=index-_min; - assert(_table[index]==-2); // Attempt to free non-allocated id. - _table[index]=-1; - _table[_last_free]=index; - #if 0 //[ - // This is only necessary if the free pool is allowed to go empty. - // Since we don't allow that, it is an optimization to comment - // this out. - if (_next_free==-1) { - _next_free=index; - } - #endif //] - _last_free=index; - ++_free; -} - - -//////////////////////////////////////////////////////////////////// -// Function: -// Access: -// Description: ...intended for debugging only. -//////////////////////////////////////////////////////////////////// -void UniqueIdAllocator:: -printTo(ostream& os) const { - os <<"[_next_free: "< 0. + _table=new U32[_size]; + assert(_table); // This should be redundant if new throws an exception. + for (U32 i=0; i<_size; ++i) { + _table[i]=i+1; + } + _table[_size-1]=-1; + _next_free=0; + _last_free=_size-1; + _free=_size; +} + +//////////////////////////////////////////////////////////////////// +// Function: +// Access: +// Description: +//////////////////////////////////////////////////////////////////// +UniqueIdAllocator:: +~UniqueIdAllocator() { + //cout<<"UniqueIdAllocator::~UniqueIdAllocator()"<>2)) { + // ...under 1/4 of the ids are free. + cerr<<"UniqueIdAllocator Error: 75% of ids allocated."<=_min); // Attempt to free out-of-range id. + assert(index<=_max); // Attempt to free out-of-range id. + index=index-_min; + assert(_table[index]==-2); // Attempt to free non-allocated id. + _table[index]=-1; + _table[_last_free]=index; + #if 0 //[ + // This is only necessary if the free pool is allowed to go empty. + // Since we don't allow that, it is an optimization to comment + // this out. + if (_next_free==-1) { + _next_free=index; + } + #endif //] + _last_free=index; + ++_free; +} + + +//////////////////////////////////////////////////////////////////// +// Function: +// Access: +// Description: ...intended for debugging only. +//////////////////////////////////////////////////////////////////// +void UniqueIdAllocator:: +printTo(ostream& os) const { + os <<"[_next_free: "<