mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Fix memory leaks.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3285 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
3adc7c3cb2
commit
2bef3f2da6
@ -67,13 +67,13 @@ BasicCellHelpValue(BasicCell *cell)
|
||||
|
||||
/* ===================================================== */
|
||||
|
||||
void
|
||||
xaccInitBasicCell (BasicCell *cell)
|
||||
static void
|
||||
xaccClearBasicCell (BasicCell *cell)
|
||||
{
|
||||
cell->changed = 0;
|
||||
cell->conditionally_changed = 0;
|
||||
|
||||
cell->value = g_strdup("");
|
||||
cell->value = NULL;
|
||||
cell->blank_help = NULL;
|
||||
cell->set_value = NULL;
|
||||
cell->enter_cell = NULL;
|
||||
@ -83,13 +83,23 @@ xaccInitBasicCell (BasicCell *cell)
|
||||
cell->realize = NULL;
|
||||
cell->move = NULL;
|
||||
cell->destroy = NULL;
|
||||
cell->get_help_value = BasicCellHelpValue;
|
||||
cell->get_help_value = NULL;
|
||||
|
||||
cell->is_popup = FALSE;
|
||||
|
||||
cell->gui_private = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
xaccInitBasicCell (BasicCell *cell)
|
||||
{
|
||||
xaccClearBasicCell (cell);
|
||||
|
||||
cell->value = g_strdup ("");
|
||||
|
||||
cell->get_help_value = BasicCellHelpValue;
|
||||
}
|
||||
|
||||
/* ===================================================== */
|
||||
|
||||
void
|
||||
@ -107,7 +117,7 @@ xaccDestroyBasicCell (BasicCell *cell)
|
||||
cell->blank_help = NULL;
|
||||
|
||||
/* help prevent access to freed memory */
|
||||
xaccInitBasicCell (cell);
|
||||
xaccClearBasicCell (cell);
|
||||
|
||||
/* free the object itself */
|
||||
g_free (cell);
|
||||
@ -121,14 +131,16 @@ xaccSetBasicCellValue (BasicCell *cell, const char *val)
|
||||
CellSetValueFunc cb;
|
||||
|
||||
cb = cell->set_value;
|
||||
if (cb) {
|
||||
if (cb)
|
||||
{
|
||||
/* avoid recursion by disabling the
|
||||
* callback while it's being called. */
|
||||
cell->set_value = NULL;
|
||||
cb (cell, val);
|
||||
cell->set_value = cb;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
g_free (cell->value);
|
||||
if (val)
|
||||
cell->value = g_strdup (val);
|
||||
@ -145,13 +157,12 @@ xaccSetBasicCellBlankHelp (BasicCell *cell, const char *blank_help)
|
||||
if (cell == NULL)
|
||||
return;
|
||||
|
||||
if (cell->blank_help != NULL)
|
||||
g_free(cell->blank_help);
|
||||
g_free (cell->blank_help);
|
||||
|
||||
if (blank_help == NULL)
|
||||
cell->blank_help = NULL;
|
||||
else
|
||||
cell->blank_help = g_strdup(blank_help);
|
||||
cell->blank_help = g_strdup (blank_help);
|
||||
}
|
||||
|
||||
/* ===================================================== */
|
||||
|
@ -80,6 +80,9 @@ gnc_cellblock_cell_destroy (gpointer _cb_cell, gpointer user_data)
|
||||
if (cb_cell == NULL)
|
||||
return;
|
||||
|
||||
cb_cell->cell = NULL;
|
||||
cb_cell->cell_type = -1;
|
||||
|
||||
g_free(cb_cell->label);
|
||||
cb_cell->label = NULL;
|
||||
|
||||
|
@ -161,7 +161,7 @@ xaccMallocNumCell (void)
|
||||
{
|
||||
NumCell *cell;
|
||||
|
||||
cell = g_new(NumCell, 1);
|
||||
cell = g_new0 (NumCell, 1);
|
||||
|
||||
xaccInitNumCell (cell);
|
||||
|
||||
|
@ -199,7 +199,7 @@ xaccMallocPriceCell (void)
|
||||
{
|
||||
PriceCell *cell;
|
||||
|
||||
cell = g_new(PriceCell, 1);
|
||||
cell = g_new0 (PriceCell, 1);
|
||||
|
||||
xaccInitPriceCell (cell);
|
||||
|
||||
|
@ -170,7 +170,7 @@ xaccMallocQuickFillCell (void)
|
||||
{
|
||||
QuickFillCell *cell;
|
||||
|
||||
cell = g_new(QuickFillCell, 1);
|
||||
cell = g_new0 (QuickFillCell, 1);
|
||||
|
||||
xaccInitQuickFillCell (cell);
|
||||
|
||||
|
@ -54,6 +54,8 @@ static RecnCellStringGetter string_getter = NULL;
|
||||
/* This static indicates the debugging module that this .o belongs to. */
|
||||
static short module = MOD_REGISTER;
|
||||
|
||||
static void RecnSetValue (BasicCell *_cell, const char *value);
|
||||
|
||||
|
||||
/* ================================================ */
|
||||
|
||||
@ -107,12 +109,23 @@ RecnEnter (BasicCell *_cell,
|
||||
|
||||
/* ================================================ */
|
||||
|
||||
static void
|
||||
xaccInitRecnCell (RecnCell *cell)
|
||||
{
|
||||
xaccInitBasicCell(&cell->cell);
|
||||
|
||||
xaccRecnCellSetFlag(cell, NREC);
|
||||
|
||||
cell->cell.enter_cell = RecnEnter;
|
||||
cell->cell.set_value = RecnSetValue;
|
||||
}
|
||||
|
||||
RecnCell *
|
||||
xaccMallocRecnCell (void)
|
||||
{
|
||||
RecnCell * cell;
|
||||
|
||||
cell = g_new(RecnCell, 1);
|
||||
cell = g_new0 (RecnCell, 1);
|
||||
|
||||
xaccInitRecnCell (cell);
|
||||
|
||||
@ -156,19 +169,6 @@ RecnSetValue (BasicCell *_cell, const char *value)
|
||||
|
||||
/* ================================================ */
|
||||
|
||||
void
|
||||
xaccInitRecnCell (RecnCell *cell)
|
||||
{
|
||||
xaccInitBasicCell(&cell->cell);
|
||||
|
||||
xaccRecnCellSetFlag(cell, NREC);
|
||||
|
||||
cell->cell.enter_cell = RecnEnter;
|
||||
cell->cell.set_value = RecnSetValue;
|
||||
}
|
||||
|
||||
/* ================================================ */
|
||||
|
||||
void
|
||||
xaccDestroyRecnCell (RecnCell *cell)
|
||||
{
|
||||
|
@ -50,7 +50,6 @@ typedef struct _RecnCell
|
||||
} RecnCell;
|
||||
|
||||
RecnCell * xaccMallocRecnCell (void);
|
||||
void xaccInitRecnCell (RecnCell *cell);
|
||||
void xaccDestroyRecnCell (RecnCell *cell);
|
||||
|
||||
void xaccRecnCellSetFlag (RecnCell *cell, char reconciled_flag);
|
||||
|
@ -978,6 +978,7 @@ xaccDestroySplitRegister (SplitRegister *reg)
|
||||
reg->cursor_journal_double = NULL;
|
||||
reg->cursor_split = NULL;
|
||||
|
||||
xaccDestroyBasicCell (reg->nullCell);
|
||||
xaccDestroyDateCell (reg->dateCell);
|
||||
xaccDestroyNumCell (reg->numCell);
|
||||
xaccDestroyQuickFillCell (reg->descCell);
|
||||
@ -999,6 +1000,7 @@ xaccDestroySplitRegister (SplitRegister *reg)
|
||||
xaccDestroyPriceCell (reg->tbalanceCell);
|
||||
xaccDestroyQuickFillCell (reg->notesCell);
|
||||
|
||||
reg->nullCell = NULL;
|
||||
reg->dateCell = NULL;
|
||||
reg->numCell = NULL;
|
||||
reg->descCell = NULL;
|
||||
|
@ -69,11 +69,6 @@ xaccMallocTextCell (void)
|
||||
void
|
||||
xaccInitTextCell (BasicCell *cell)
|
||||
{
|
||||
xaccInitBasicCell (cell);
|
||||
|
||||
g_free (cell->value);
|
||||
cell->value = g_strdup ("");
|
||||
|
||||
cell->modify_verify = TextMV;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user