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:
parent
b0291c651b
commit
0ad219a8f4
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user