Constify some Split and Transaction functions.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@12229 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Chris Shoemaker 2005-12-31 23:35:55 +00:00
parent 2b7c1430e1
commit d96b0c7d81
5 changed files with 31 additions and 31 deletions

View File

@ -78,8 +78,8 @@ const char *void_former_notes_str = "void-former-notes";
/* This static indicates the debugging module that this .o belongs to. */
static QofLogModule log_module = GNC_MOD_ENGINE;
G_INLINE_FUNC void check_open (Transaction *trans);
void check_open (Transaction *trans)
G_INLINE_FUNC void check_open (const Transaction *trans);
void check_open (const Transaction *trans)
{
if (trans && 0 >= trans->inst.editlevel)
{
@ -152,7 +152,7 @@ xaccMallocSplit(QofBook *book)
*/
static Split *
xaccDupeSplit (Split *s)
xaccDupeSplit (const Split *s)
{
Split *split = g_new0 (Split, 1);
@ -190,7 +190,7 @@ xaccDupeSplit (Split *s)
}
static Split *
xaccSplitClone (Split *s)
xaccSplitClone (const Split *s)
{
QofCollection *col;
Split *split = g_new0 (Split, 1);
@ -218,6 +218,7 @@ xaccSplitClone (Split *s)
xaccAccountInsertSplit(s->acc, split);
if (s->lot)
{
/* FIXME: Doesn't look right. */
s->lot->splits = g_list_append (s->lot->splits, split);
s->lot->is_closed = -1;
}
@ -226,7 +227,7 @@ xaccSplitClone (Split *s)
#ifdef DUMP_FUNCTIONS
static void
xaccSplitDump (Split *split, const char *tag)
xaccSplitDump (const Split *split, const char *tag)
{
printf(" %s Split %p", tag, split);
printf(" GUID: %s\n", guid_to_string(&split->guid));
@ -538,8 +539,8 @@ void mark_trans (Transaction *trans)
}
}
G_INLINE_FUNC void gen_event (Split *split);
void gen_event (Split *split)
G_INLINE_FUNC void gen_event (const Split *split);
void gen_event (const Split *split)
{
Account *account = split->acc;
Transaction *trans = split->parent;
@ -866,7 +867,7 @@ xaccMallocTransaction (QofBook *book)
#ifdef DUMP_FUNCTIONS
void
xaccTransDump (Transaction *trans, const char *tag)
xaccTransDump (const Transaction *trans, const char *tag)
{
GList *node;
@ -932,7 +933,7 @@ xaccTransSortSplits (Transaction *trans)
*/
Transaction *
xaccDupeTransaction (Transaction *t)
xaccDupeTransaction (const Transaction *t)
{
Transaction *trans;
GList *node;
@ -976,7 +977,7 @@ xaccDupeTransaction (Transaction *t)
* a full fledged transaction with unique guid, splits, etc.
*/
Transaction *
xaccTransClone (Transaction *t)
xaccTransClone (const Transaction *t)
{
Transaction *trans;
Split *split;
@ -1079,8 +1080,8 @@ xaccFreeTransaction (Transaction *trans)
static gint
compare_split_guids (gconstpointer a, gconstpointer b)
{
Split *sa = (Split *) a;
Split *sb = (Split *) b;
const Split *sa = a;
const Split *sb = b;
if (sa == sb) return 0;
if (!sa || !sb) return 1;
@ -1945,7 +1946,7 @@ xaccTransGetVersion (const Transaction *trans)
\********************************************************************/
static void
xaccTransRemoveSplit (Transaction *trans, Split *split)
xaccTransRemoveSplit (Transaction *trans, const Split *split)
{
if (trans == NULL)
return;
@ -2285,7 +2286,7 @@ xaccSplitGetCorrAccountCode(const Split *sa)
}
int
xaccSplitCompareAccountFullNames(Split *sa, Split *sb)
xaccSplitCompareAccountFullNames(const Split *sa, const Split *sb)
{
Account *aa, *ab;
char *full_a, *full_b;
@ -2308,7 +2309,7 @@ xaccSplitCompareAccountFullNames(Split *sa, Split *sb)
int
xaccSplitCompareAccountCodes(Split *sa, Split *sb)
xaccSplitCompareAccountCodes(const Split *sa, const Split *sb)
{
Account *aa, *ab;
if (!sa && !sb) return 0;
@ -2322,7 +2323,7 @@ xaccSplitCompareAccountCodes(Split *sa, Split *sb)
}
int
xaccSplitCompareOtherAccountFullNames(Split *sa, Split *sb)
xaccSplitCompareOtherAccountFullNames(const Split *sa, const Split *sb)
{
char *ca, *cb;
int retval;
@ -2343,7 +2344,7 @@ xaccSplitCompareOtherAccountFullNames(Split *sa, Split *sb)
}
int
xaccSplitCompareOtherAccountCodes(Split *sa, Split *sb)
xaccSplitCompareOtherAccountCodes(const Split *sa, const Split *sb)
{
const char *ca, *cb;
if (!sa && !sb) return 0;
@ -3016,7 +3017,7 @@ gnc_book_count_transactions(QofBook *book)
\********************************************************************/
Account *
xaccGetAccountByName (Transaction *trans, const char * name)
xaccGetAccountByName (const Transaction *trans, const char * name)
{
Account *acc = NULL;
GList *node;
@ -3043,7 +3044,7 @@ xaccGetAccountByName (Transaction *trans, const char * name)
\********************************************************************/
Account *
xaccGetAccountByFullName (Transaction *trans, const char * name,
xaccGetAccountByFullName (const Transaction *trans, const char * name,
const char separator)
{
Account *acc = NULL;

View File

@ -140,7 +140,7 @@ void xaccTransDestroy (Transaction *trans);
The xaccTransClone() method will create a complete copy of an
existing transaction.
*/
Transaction * xaccTransClone (Transaction *t);
Transaction * xaccTransClone (const Transaction *t);
/** Equality.
*
@ -729,18 +729,18 @@ int xaccSplitDateOrder (const Split *sa, const Split *sb);
/** Compare two splits by full name of account. Returns similar to
* strcmp. */
int xaccSplitCompareAccountFullNames(Split *sa, Split *sb);
int xaccSplitCompareAccountFullNames(const Split *sa, const Split *sb);
/** Compare two splits by code of account. Returns similar to
* strcmp. */
int xaccSplitCompareAccountCodes(Split *sa, Split *sb);
int xaccSplitCompareAccountCodes(const Split *sa, const Split *sb);
/** Compare two splits by full name of the other account. Returns
* similar to strcmp. This function attempts to find the split on the
* other side of a transaction and compare on it. */
int xaccSplitCompareOtherAccountFullNames(Split *sa, Split *sb);
int xaccSplitCompareOtherAccountFullNames(const Split *sa, const Split *sb);
/** Compare two splits by code of the other account. Returns similar
* to strcmp. This function attempts to find the split on the
* other side of a transaction and compare on it. */
int xaccSplitCompareOtherAccountCodes(Split *sa, Split *sb);
int xaccSplitCompareOtherAccountCodes(const Split *sa, const Split *sb);
/**
@ -782,10 +782,10 @@ void xaccSplitSetSharePrice (Split *split, gnc_numeric price);
/** The xaccGetAccountByName() is a convenience routine that
* is essentially identical to xaccGetPeerAccountFromName(),
* except that it accepts the handy transaction as root.*/
Account * xaccGetAccountByName (Transaction *trans, const char *name);
Account * xaccGetAccountByName (const Transaction *trans, const char *name);
/** The xaccGetAccountByFullName routine is similar to xaccGetAccountByName, but uses
* full names using the given separator.*/
Account * xaccGetAccountByFullName (Transaction *trans,
Account * xaccGetAccountByFullName (const Transaction *trans,
const char *name,
const char separator);

View File

@ -230,7 +230,7 @@ void xaccFreeSplit (Split *split); /* frees memory */
* Another 'feature': the splits point at the old transaction
* as the parent, not the new transaction.
*/
Transaction * xaccDupeTransaction (Transaction *t);
Transaction * xaccDupeTransaction (const Transaction *t);
/* Compute the value of a list of splits in the given currency,
* excluding the skip_me split. */

View File

@ -625,7 +625,7 @@ xaccSplitAssign (Split *split)
/* ============================================================== */
Split *
xaccSplitGetCapGainsSplit (Split *split)
xaccSplitGetCapGainsSplit (const Split *split)
{
KvpValue *val;
GUID *gains_guid;

View File

@ -147,9 +147,8 @@ void xaccAccountSetDefaultGainAccount (Account *acc, Account *gains_acct);
* that records the cap gains for this split. It returns NULL
* if not found. This routine does nothing more than search for
* the split recorded in the KVP key "/gains-split"
*/
Split * xaccSplitGetCapGainsSplit (Split *);
*/
Split * xaccSplitGetCapGainsSplit (const Split *);
/** The`xaccSplitAssign() routine will take the indicated
* split and, if it doesn't already belong to a lot, it will attempt