"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/burp/misc.cpp" between
Firebird-3.0.2.32703-0.tar.bz2 and Firebird-3.0.4.33054-0.tar.bz2

About: Firebird is a relational database offering many ANSI SQL standard features.

misc.cpp  (Firebird-3.0.2.32703-0.tar.bz2):misc.cpp  (Firebird-3.0.4.33054-0.tar.bz2)
skipping to change at line 34 skipping to change at line 34
* *
*/ */
#include "firebird.h" #include "firebird.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "../burp/burp.h" #include "../burp/burp.h"
#include "../burp/burp_proto.h" #include "../burp/burp_proto.h"
#include "../burp/misc_proto.h" #include "../burp/misc_proto.h"
UCHAR *MISC_alloc_burp(ULONG size)
{
/**************************************
*
* M I S C _ a l l o c _ b u r p
*
**************************************
*
* Functional description
* Allocate block of memory. Note that it always zeros out memory.
* This could be optimized.
*
**************************************/
BurpGlobals* tdgbl = BurpGlobals::getSpecific();
// Add some header space to store a list of blocks allocated for this gba
k
size += ROUNDUP(sizeof(UCHAR *), FB_ALIGNMENT);
UCHAR* block = (UCHAR*)gds__alloc(size);
if (!block)
{
// NOMEM: message & abort FREE: all items freed at gbak exit
BURP_error(238, true);
// msg 238: System memory exhaused
return NULL;
}
memset(block, 0, size);
// FREE: We keep a linked list of all gbak memory allocations, which
// are then freed when gbak exits. This is important for
// NETWARE in particular.
*((UCHAR**) block) = tdgbl->head_of_mem_list;
tdgbl->head_of_mem_list = block;
return (block + ROUNDUP(sizeof(UCHAR *), FB_ALIGNMENT));
}
void MISC_free_burp( void *free)
{
/**************************************
*
* M I S C _ f r e e _ b u r p
*
**************************************
*
* Functional description
* Release an unwanted block.
*
**************************************/
BurpGlobals* tdgbl = BurpGlobals::getSpecific();
if (free != NULL)
{
// Point at the head of the allocated block
UCHAR** block = (UCHAR**) ((UCHAR*) free - ROUNDUP(sizeof(UCHAR*)
, FB_ALIGNMENT));
// Scan for this block in the list of blocks
for (UCHAR **ptr = &tdgbl->head_of_mem_list; *ptr; ptr = (UCHAR *
*) *ptr)
{
if (*ptr == (UCHAR *) block)
{
// Found it - remove it from the list
*ptr = *block;
// and free it
gds__free(block);
return;
}
}
// We should always find the block in the list
BURP_error(238, true);
// msg 238: System memory exhausted
// (too lazy to add a better message)
}
}
// Since this code appears everywhere, it makes more sense to isolate it // Since this code appears everywhere, it makes more sense to isolate it
// in a function visible to all gbak components. // in a function visible to all gbak components.
// Given a request, if it's non-zero (compiled), deallocate it but // Given a request, if it's non-zero (compiled), deallocate it but
// without caring about a possible error. // without caring about a possible error.
void MISC_release_request_silent(isc_req_handle& req_handle) void MISC_release_request_silent(isc_req_handle& req_handle)
{ {
if (req_handle) if (req_handle)
{ {
ISC_STATUS_ARRAY req_status; ISC_STATUS_ARRAY req_status;
isc_release_request(req_status, &req_handle); isc_release_request(req_status, &req_handle);
 End of changes. 1 change blocks. 
84 lines changed or deleted 0 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)