From 0235cba2e3caff3fc09c5bc6cd5695735a7d68de Mon Sep 17 00:00:00 2001 From: Linas Vepstas Date: Wed, 25 Mar 1998 09:16:51 +0000 Subject: [PATCH] fix how transaction freeing works. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@731 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/engine/Transaction.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/engine/Transaction.c b/src/engine/Transaction.c index 5d86592eba..7ba53e70c2 100644 --- a/src/engine/Transaction.c +++ b/src/engine/Transaction.c @@ -92,13 +92,19 @@ xaccMallocSplit( void ) void xaccFreeSplit( Split *split ) { + Transaction *trans; + if (!split) return; /* free a split only if it is not claimed * by any accounts. */ if (split->acc) return; - xaccTransRemoveSplit (split->parent, split); + /* free the split only if its not a source split */ + trans = split->parent; + if (&(trans->source_split) == split) return; + + xaccTransRemoveSplit (trans, split); free(split->memo); free(split->action); @@ -255,7 +261,30 @@ xaccFreeTransaction( Transaction *trans ) s = trans->dest_splits[i]; } + /* free up the destination splits */ + i = 0; + s = trans->dest_splits[i]; + while (s) { + xaccFreeSplit (s); + i++; + s = trans->dest_splits[i]; + } + _free (trans->dest_splits); + + + /* free up the source-split related stuff. */ + free(trans->source_split.memo); + free(trans->source_split.action); + + /* just in case someone looks up freed memory ... */ + trans->source_split.memo = 0x0; + trans->source_split.reconciled = NREC; + trans->source_split.damount = 0.0; + trans->source_split.share_price = 1.0; + trans->source_split.parent = NULL; + + /* free up transaction strings */ free(trans->num); free(trans->description);