8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 05:23:03 +01:00

Updated delete operators to accept a null pointer to delete as required by c++.

This commit is contained in:
bellardo 2002-04-02 05:42:38 +00:00
parent b0291c651b
commit 0ad219a8f4
3 changed files with 14 additions and 7 deletions

View File

@ -94,11 +94,14 @@ void* API_ROUTINE gds__alloc(SLONG size_request)
ULONG API_ROUTINE gds__free(void* blk)
{
try
if (blk)
{
poolLoader.loadPool();
return FB_MemoryPool->deallocate(blk);
} catch(...) {}
try
{
poolLoader.loadPool();
return FB_MemoryPool->deallocate(blk);
} catch(...) {}
}
return 0;
}

View File

@ -100,6 +100,10 @@ namespace Firebird
allocator(MemoryPool& p, SSHORT t = 0) : pool(&p), type(t) {}
allocator(MemoryPool *p = getDefaultMemoryPool(), SSHORT t = 0) : pool(p), type(t) {}
template <class DST>
allocator(const allocator<DST> &alloc)
: pool(alloc.getPool()), type(alloc.getType()) { }
pointer allocate(size_type s, const void * = 0)
{ return (pointer) (pool ? pool->allocate(sizeof(T) * s) : gds__alloc(sizeof(T)*s)); }
void deallocate(pointer p, size_type s)
@ -122,7 +126,8 @@ namespace Firebird
return pool == rhs.pool && type == rhs.type;
}
MemoryPool *getPool() const { return pool; }
SSHORT getType() const { return type; }
private:
MemoryPool *pool;
@ -131,5 +136,4 @@ namespace Firebird
};
#endif // COMMON_ALLOCATORS_H

View File

@ -66,7 +66,7 @@ static const bool ENABLE_FREQUENT_VERIFICATION = false;
// These next variables control the Red Zone debugging offered by the memory pool
static const bool ENABLE_RED_ZONES = false; // set to false to disable the red zones
static const bool ENABLE_RED_ZONES = true; // set to false to disable the red zones
static const int RED_ZONE_FILL = 0xFD;
static const int BEFORE_RED_ZONE_SIZE = 3; // The size of the red zone BEFORE the memory,
// in ALLOCATION UNITS! Does NOT need to be set to