mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-29 19:11:24 -04:00
suppressed potential SIGSEGV as exit time
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4068 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
3ae378d9b9
commit
800cc281c5
2 changed files with 23 additions and 0 deletions
|
@ -170,14 +170,21 @@ void FixedAllocator::printStatistics() const
|
|||
SmallObjectAllocator::SmallObjectAllocator(size_t maxObjectSize)
|
||||
: _maxObjectSize(maxObjectSize)
|
||||
{
|
||||
RsStackMutex m(SmallObject::_mtx) ;
|
||||
|
||||
_lastAlloc = NULL ;
|
||||
_lastDealloc = NULL ;
|
||||
_active = true ;
|
||||
}
|
||||
|
||||
SmallObjectAllocator::~SmallObjectAllocator()
|
||||
{
|
||||
RsStackMutex m(SmallObject::_mtx) ;
|
||||
|
||||
for(std::map<int,FixedAllocator*>::const_iterator it(_pool.begin());it!=_pool.end();++it)
|
||||
delete it->second ;
|
||||
|
||||
_active = false ;
|
||||
}
|
||||
|
||||
void *SmallObjectAllocator::allocate(size_t bytes)
|
||||
|
@ -255,6 +262,10 @@ void *SmallObject::operator new(size_t size)
|
|||
#endif
|
||||
|
||||
RsStackMutex m(_mtx) ;
|
||||
|
||||
if(!_allocator._active)
|
||||
return (void*)NULL;
|
||||
|
||||
void *p = _allocator.allocate(size) ;
|
||||
#ifdef DEBUG_MEMORY
|
||||
std::cerr << "new RsItem: " << p << ", size=" << size << std::endl;
|
||||
|
@ -265,6 +276,10 @@ void *SmallObject::operator new(size_t size)
|
|||
void SmallObject::operator delete(void *p,size_t size)
|
||||
{
|
||||
RsStackMutex m(_mtx) ;
|
||||
|
||||
if(!_allocator._active)
|
||||
return ;
|
||||
|
||||
_allocator.deallocate(p,size) ;
|
||||
#ifdef DEBUG_MEMORY
|
||||
std::cerr << "del RsItem: " << p << ", size=" << size << std::endl;
|
||||
|
@ -274,6 +289,10 @@ void SmallObject::operator delete(void *p,size_t size)
|
|||
void SmallObject::printStatistics()
|
||||
{
|
||||
RsStackMutex m(_mtx) ;
|
||||
|
||||
if(!_allocator._active)
|
||||
return ;
|
||||
|
||||
_allocator.printStatistics() ;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue