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
|
static void
|
||||||
xaccInitBasicCell (BasicCell *cell)
|
xaccClearBasicCell (BasicCell *cell)
|
||||||
{
|
{
|
||||||
cell->changed = 0;
|
cell->changed = 0;
|
||||||
cell->conditionally_changed = 0;
|
cell->conditionally_changed = 0;
|
||||||
|
|
||||||
cell->value = g_strdup("");
|
cell->value = NULL;
|
||||||
cell->blank_help = NULL;
|
cell->blank_help = NULL;
|
||||||
cell->set_value = NULL;
|
cell->set_value = NULL;
|
||||||
cell->enter_cell = NULL;
|
cell->enter_cell = NULL;
|
||||||
@ -83,13 +83,23 @@ xaccInitBasicCell (BasicCell *cell)
|
|||||||
cell->realize = NULL;
|
cell->realize = NULL;
|
||||||
cell->move = NULL;
|
cell->move = NULL;
|
||||||
cell->destroy = NULL;
|
cell->destroy = NULL;
|
||||||
cell->get_help_value = BasicCellHelpValue;
|
cell->get_help_value = NULL;
|
||||||
|
|
||||||
cell->is_popup = FALSE;
|
cell->is_popup = FALSE;
|
||||||
|
|
||||||
cell->gui_private = NULL;
|
cell->gui_private = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xaccInitBasicCell (BasicCell *cell)
|
||||||
|
{
|
||||||
|
xaccClearBasicCell (cell);
|
||||||
|
|
||||||
|
cell->value = g_strdup ("");
|
||||||
|
|
||||||
|
cell->get_help_value = BasicCellHelpValue;
|
||||||
|
}
|
||||||
|
|
||||||
/* ===================================================== */
|
/* ===================================================== */
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -107,7 +117,7 @@ xaccDestroyBasicCell (BasicCell *cell)
|
|||||||
cell->blank_help = NULL;
|
cell->blank_help = NULL;
|
||||||
|
|
||||||
/* help prevent access to freed memory */
|
/* help prevent access to freed memory */
|
||||||
xaccInitBasicCell (cell);
|
xaccClearBasicCell (cell);
|
||||||
|
|
||||||
/* free the object itself */
|
/* free the object itself */
|
||||||
g_free (cell);
|
g_free (cell);
|
||||||
@ -121,14 +131,16 @@ xaccSetBasicCellValue (BasicCell *cell, const char *val)
|
|||||||
CellSetValueFunc cb;
|
CellSetValueFunc cb;
|
||||||
|
|
||||||
cb = cell->set_value;
|
cb = cell->set_value;
|
||||||
if (cb) {
|
if (cb)
|
||||||
|
{
|
||||||
/* avoid recursion by disabling the
|
/* avoid recursion by disabling the
|
||||||
* callback while it's being called. */
|
* callback while it's being called. */
|
||||||
cell->set_value = NULL;
|
cell->set_value = NULL;
|
||||||
cb (cell, val);
|
cb (cell, val);
|
||||||
cell->set_value = cb;
|
cell->set_value = cb;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
g_free (cell->value);
|
g_free (cell->value);
|
||||||
if (val)
|
if (val)
|
||||||
cell->value = g_strdup (val);
|
cell->value = g_strdup (val);
|
||||||
@ -145,7 +157,6 @@ xaccSetBasicCellBlankHelp (BasicCell *cell, const char *blank_help)
|
|||||||
if (cell == NULL)
|
if (cell == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (cell->blank_help != NULL)
|
|
||||||
g_free (cell->blank_help);
|
g_free (cell->blank_help);
|
||||||
|
|
||||||
if (blank_help == NULL)
|
if (blank_help == NULL)
|
||||||
|
@ -80,6 +80,9 @@ gnc_cellblock_cell_destroy (gpointer _cb_cell, gpointer user_data)
|
|||||||
if (cb_cell == NULL)
|
if (cb_cell == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
cb_cell->cell = NULL;
|
||||||
|
cb_cell->cell_type = -1;
|
||||||
|
|
||||||
g_free(cb_cell->label);
|
g_free(cb_cell->label);
|
||||||
cb_cell->label = NULL;
|
cb_cell->label = NULL;
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ xaccMallocNumCell (void)
|
|||||||
{
|
{
|
||||||
NumCell *cell;
|
NumCell *cell;
|
||||||
|
|
||||||
cell = g_new(NumCell, 1);
|
cell = g_new0 (NumCell, 1);
|
||||||
|
|
||||||
xaccInitNumCell (cell);
|
xaccInitNumCell (cell);
|
||||||
|
|
||||||
|
@ -199,7 +199,7 @@ xaccMallocPriceCell (void)
|
|||||||
{
|
{
|
||||||
PriceCell *cell;
|
PriceCell *cell;
|
||||||
|
|
||||||
cell = g_new(PriceCell, 1);
|
cell = g_new0 (PriceCell, 1);
|
||||||
|
|
||||||
xaccInitPriceCell (cell);
|
xaccInitPriceCell (cell);
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ xaccMallocQuickFillCell (void)
|
|||||||
{
|
{
|
||||||
QuickFillCell *cell;
|
QuickFillCell *cell;
|
||||||
|
|
||||||
cell = g_new(QuickFillCell, 1);
|
cell = g_new0 (QuickFillCell, 1);
|
||||||
|
|
||||||
xaccInitQuickFillCell (cell);
|
xaccInitQuickFillCell (cell);
|
||||||
|
|
||||||
|
@ -54,6 +54,8 @@ static RecnCellStringGetter string_getter = NULL;
|
|||||||
/* This static indicates the debugging module that this .o belongs to. */
|
/* This static indicates the debugging module that this .o belongs to. */
|
||||||
static short module = MOD_REGISTER;
|
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 *
|
RecnCell *
|
||||||
xaccMallocRecnCell (void)
|
xaccMallocRecnCell (void)
|
||||||
{
|
{
|
||||||
RecnCell * cell;
|
RecnCell * cell;
|
||||||
|
|
||||||
cell = g_new(RecnCell, 1);
|
cell = g_new0 (RecnCell, 1);
|
||||||
|
|
||||||
xaccInitRecnCell (cell);
|
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
|
void
|
||||||
xaccDestroyRecnCell (RecnCell *cell)
|
xaccDestroyRecnCell (RecnCell *cell)
|
||||||
{
|
{
|
||||||
|
@ -50,7 +50,6 @@ typedef struct _RecnCell
|
|||||||
} RecnCell;
|
} RecnCell;
|
||||||
|
|
||||||
RecnCell * xaccMallocRecnCell (void);
|
RecnCell * xaccMallocRecnCell (void);
|
||||||
void xaccInitRecnCell (RecnCell *cell);
|
|
||||||
void xaccDestroyRecnCell (RecnCell *cell);
|
void xaccDestroyRecnCell (RecnCell *cell);
|
||||||
|
|
||||||
void xaccRecnCellSetFlag (RecnCell *cell, char reconciled_flag);
|
void xaccRecnCellSetFlag (RecnCell *cell, char reconciled_flag);
|
||||||
|
@ -978,6 +978,7 @@ xaccDestroySplitRegister (SplitRegister *reg)
|
|||||||
reg->cursor_journal_double = NULL;
|
reg->cursor_journal_double = NULL;
|
||||||
reg->cursor_split = NULL;
|
reg->cursor_split = NULL;
|
||||||
|
|
||||||
|
xaccDestroyBasicCell (reg->nullCell);
|
||||||
xaccDestroyDateCell (reg->dateCell);
|
xaccDestroyDateCell (reg->dateCell);
|
||||||
xaccDestroyNumCell (reg->numCell);
|
xaccDestroyNumCell (reg->numCell);
|
||||||
xaccDestroyQuickFillCell (reg->descCell);
|
xaccDestroyQuickFillCell (reg->descCell);
|
||||||
@ -999,6 +1000,7 @@ xaccDestroySplitRegister (SplitRegister *reg)
|
|||||||
xaccDestroyPriceCell (reg->tbalanceCell);
|
xaccDestroyPriceCell (reg->tbalanceCell);
|
||||||
xaccDestroyQuickFillCell (reg->notesCell);
|
xaccDestroyQuickFillCell (reg->notesCell);
|
||||||
|
|
||||||
|
reg->nullCell = NULL;
|
||||||
reg->dateCell = NULL;
|
reg->dateCell = NULL;
|
||||||
reg->numCell = NULL;
|
reg->numCell = NULL;
|
||||||
reg->descCell = NULL;
|
reg->descCell = NULL;
|
||||||
|
@ -69,11 +69,6 @@ xaccMallocTextCell (void)
|
|||||||
void
|
void
|
||||||
xaccInitTextCell (BasicCell *cell)
|
xaccInitTextCell (BasicCell *cell)
|
||||||
{
|
{
|
||||||
xaccInitBasicCell (cell);
|
|
||||||
|
|
||||||
g_free (cell->value);
|
|
||||||
cell->value = g_strdup ("");
|
|
||||||
|
|
||||||
cell->modify_verify = TextMV;
|
cell->modify_verify = TextMV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user