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

Fixed some memory leaks

This commit is contained in:
skidder 2002-09-26 18:13:02 +00:00
parent 3acdfa81c4
commit 040bd8e499
4 changed files with 25 additions and 18 deletions

View File

@ -30,7 +30,7 @@
* This closes the heart of SF Bug #518282. * This closes the heart of SF Bug #518282.
*/ */
/* /*
$Id: cmp.cpp,v 1.11 2002-09-25 17:12:09 skidder Exp $ $Id: cmp.cpp,v 1.12 2002-09-26 18:13:02 skidder Exp $
*/ */
#include "firebird.h" #include "firebird.h"
@ -356,6 +356,8 @@ REQ DLL_EXPORT CMP_compile2(TDBB tdbb, UCHAR* blr, USHORT internal_flag)
SET_TDBB(tdbb); SET_TDBB(tdbb);
JrdMemoryPool* old_pool = tdbb->tdbb_default; JrdMemoryPool* old_pool = tdbb->tdbb_default;
/* 26.09.2002 Nickolay Samofatov: default memory pool will become statement pool
and will be freed by CMP_release */
JrdMemoryPool* new_pool = FB_NEW(*tdbb->tdbb_database->dbb_permanent) JrdMemoryPool* new_pool = FB_NEW(*tdbb->tdbb_database->dbb_permanent)
JrdMemoryPool; JrdMemoryPool;
tdbb->tdbb_default = new_pool; tdbb->tdbb_default = new_pool;
@ -388,6 +390,7 @@ REQ DLL_EXPORT CMP_compile2(TDBB tdbb, UCHAR* blr, USHORT internal_flag)
} else if (new_pool) { } else if (new_pool) {
// TMN: Are we not to release the pool, just beqause // TMN: Are we not to release the pool, just beqause
// we have a request?! // we have a request?!
// Nickolay Samofatv: It well be freed by CMP_release otherwise
delete new_pool; delete new_pool;
} }
ERR_punt(); ERR_punt();

View File

@ -3194,6 +3194,7 @@ static void get_procedure_dependencies(DFW work)
if (procedure && !NULL_BLOB(blob_id)) if (procedure && !NULL_BLOB(blob_id))
{ {
old_pool = tdbb->tdbb_default; old_pool = tdbb->tdbb_default;
/* Nickolay Samofatov: allocate statement memory pool... */
tdbb->tdbb_default = FB_NEW(*dbb->dbb_permanent) JrdMemoryPool; tdbb->tdbb_default = FB_NEW(*dbb->dbb_permanent) JrdMemoryPool;
MET_get_dependencies(tdbb, MET_get_dependencies(tdbb,
(struct rel*)NULL_PTR, (struct rel*)NULL_PTR,

View File

@ -226,18 +226,29 @@ static REC_MUTX_T databases_rec_mutex;
void trig::compile(tdbb* _tdbb) { void trig::compile(tdbb* _tdbb) {
if (!request && !compile_in_progress) { if (!request && !compile_in_progress) {
JrdMemoryPool* old_pool;
SET_TDBB(_tdbb); SET_TDBB(_tdbb);
compile_in_progress = TRUE; compile_in_progress = TRUE;
old_pool = _tdbb->tdbb_default; JrdMemoryPool* old_pool = _tdbb->tdbb_default,
_tdbb->tdbb_default = FB_NEW(*getDefaultMemoryPool()) JrdMemoryPool; *new_pool = FB_NEW(*getDefaultMemoryPool()) JrdMemoryPool;
/* Allocate statement memory pool */
_tdbb->tdbb_default = new_pool;
// Trigger request is not compiled yet. Lets do it now // Trigger request is not compiled yet. Lets do it now
try {
PAR_blr(_tdbb, relation, blr->str_data, PAR_blr(_tdbb, relation, blr->str_data,
(CSB)NULL_PTR, (CSB*)NULL_PTR, &request, TRUE, (CSB)NULL_PTR, (CSB*)NULL_PTR, &request, TRUE,
(USHORT)(flags & TRG_ignore_perm ? csb_ignore_perm : 0)); (USHORT)(flags & TRG_ignore_perm ? csb_ignore_perm : 0));
_tdbb->tdbb_default = old_pool; _tdbb->tdbb_default = old_pool;
} catch (...) {
_tdbb->tdbb_default = old_pool;
compile_in_progress = FALSE;
if (request)
CMP_release(_tdbb,request);
else
delete new_pool;
throw;
}
_tdbb->tdbb_default = old_pool;
if (name) if (name)
request->req_trg_name = (TEXT *)name->str_data; request->req_trg_name = (TEXT *)name->str_data;

View File

@ -35,7 +35,7 @@
* 2002-09-16 Nickolay Samofatov - Deferred trigger compilation changes * 2002-09-16 Nickolay Samofatov - Deferred trigger compilation changes
*/ */
/* /*
$Id: met.epp,v 1.18 2002-09-25 17:12:10 skidder Exp $ $Id: met.epp,v 1.19 2002-09-26 18:13:02 skidder Exp $
*/ */
// This MUST be at the top of the file // This MUST be at the top of the file
#ifdef DARWIN #ifdef DARWIN
@ -3610,22 +3610,14 @@ static void get_trigger(
SET_TDBB(tdbb); SET_TDBB(tdbb);
JrdMemoryPool* old_pool;
SET_TDBB(tdbb);
if (!blob_id[0] && !blob_id[1]) if (!blob_id[0] && !blob_id[1])
return; return;
old_pool = tdbb->tdbb_default;
tdbb->tdbb_default = FB_NEW(*getDefaultMemoryPool()) JrdMemoryPool;
DBB dbb = tdbb->tdbb_database; DBB dbb = tdbb->tdbb_database;
BLB blob = BLB_open(tdbb, dbb->dbb_sys_trans, (BID)blob_id); BLB blob = BLB_open(tdbb, dbb->dbb_sys_trans, (BID)blob_id);
SLONG length = blob->blb_length + 10; SLONG length = blob->blb_length + 10;
STR blr = FB_NEW_RPT(*tdbb->tdbb_default,length) str(); STR blr = FB_NEW_RPT(*dbb->dbb_permanent,length) str();
BLB_get_data(tdbb, blob, blr->str_data, length); BLB_get_data(tdbb, blob, blr->str_data, length);
tdbb->tdbb_default = old_pool;
save_trigger_data(tdbb, ptr, relation, NULL, blr, name, sys_trigger, flags); save_trigger_data(tdbb, ptr, relation, NULL, blr, name, sys_trigger, flags);
} }