mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-24 09:23:03 +01:00
Cleanup. Let's finally use a single (and standard) behavior of the allocator.
This commit is contained in:
parent
e5ede31aa2
commit
e0179c672d
@ -420,26 +420,6 @@ MemBlock* MemoryPool::alloc(const size_t length) throw (std::bad_alloc)
|
||||
return block;
|
||||
}
|
||||
|
||||
void* MemoryPool::allocate_nothrow(size_t size
|
||||
#ifdef DEBUG_GDS_ALLOC
|
||||
, const char* file, int line
|
||||
#endif
|
||||
) throw ()
|
||||
{
|
||||
try
|
||||
{
|
||||
#ifdef DEBUG_GDS_ALLOC
|
||||
return allocate(size, file, line);
|
||||
#else
|
||||
return allocate(size);
|
||||
#endif
|
||||
}
|
||||
catch (const Firebird::Exception&)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void* MemoryPool::allocate(size_t size
|
||||
#ifdef DEBUG_GDS_ALLOC
|
||||
, const char* fileName, int line
|
||||
|
@ -303,13 +303,6 @@ public:
|
||||
static void deallocate(void* block) throw ();
|
||||
void validate(void) throw ();
|
||||
|
||||
// Allocate memory block. In case of problems this method returns NULL
|
||||
void* allocate_nothrow(size_t size
|
||||
#ifdef DEBUG_GDS_ALLOC
|
||||
, const char* file = NULL, int line = 0
|
||||
#endif
|
||||
) throw ();
|
||||
|
||||
#ifdef LIBC_CALLS_NEW
|
||||
static void* globalAlloc(size_t s) throw (std::bad_alloc);
|
||||
#else
|
||||
|
@ -3534,8 +3534,7 @@ static void expand_buffers(thread_db* tdbb, ULONG number)
|
||||
if (!num_in_seg)
|
||||
{
|
||||
const size_t alloc_size = dbb->dbb_page_size * (num_per_seg + 1);
|
||||
memory = (UCHAR*) dbb->dbb_bufferpool->allocate_nothrow(alloc_size);
|
||||
// NOMEM: crash!
|
||||
memory = (UCHAR*) dbb->dbb_bufferpool->allocate(alloc_size);
|
||||
new_block->bcb_memory.push(memory);
|
||||
memory = (UCHAR *) FB_ALIGN((U_IPTR) memory, dbb->dbb_page_size);
|
||||
num_in_seg = num_per_seg;
|
||||
|
@ -217,12 +217,19 @@ static gds_msg* global_default_msg = NULL;
|
||||
|
||||
VoidPtr API_ROUTINE gds__alloc_debug(SLONG size_request, const TEXT* filename, ULONG lineno)
|
||||
{
|
||||
return getDefaultMemoryPool()->allocate_nothrow(size_request
|
||||
try
|
||||
{
|
||||
return getDefaultMemoryPool()->allocate(size_request
|
||||
#ifdef DEBUG_GDS_ALLOC
|
||||
, filename, lineno
|
||||
#endif
|
||||
);
|
||||
}
|
||||
catch (const Firebird::Exception&)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
ULONG API_ROUTINE gds__free(void* blk)
|
||||
{
|
||||
@ -3635,12 +3642,19 @@ void gds__trace_printer(void* /*arg*/, SSHORT offset, const TEXT* line)
|
||||
|
||||
VoidPtr API_ROUTINE gds__alloc(SLONG size_request)
|
||||
{
|
||||
return getDefaultMemoryPool()->allocate_nothrow(size_request
|
||||
try
|
||||
{
|
||||
return getDefaultMemoryPool()->allocate(size_request
|
||||
#ifdef DEBUG_GDS_ALLOC
|
||||
, __FILE__, __LINE__
|
||||
#endif
|
||||
);
|
||||
}
|
||||
catch (const Firebird::Exception&)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class InitPrefix
|
||||
|
Loading…
Reference in New Issue
Block a user