Skip to content

Commit

Permalink
signature change
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@1317 57a11ea4-9604-0410-9ed3-97b8803252fd
  • Loading branch information
linas committed Oct 18, 1998
1 parent c2a7241 commit 893f6bb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
36 changes: 20 additions & 16 deletions src/engine/Group.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,9 @@ xaccRemoveAccount (Account *acc)
arr[i] = arr[j];
if( acc == arr[j] ) { i--; }
}
arr[grp->numAcc] = NULL;
} else {
arr[grp->numAcc] = NULL;
grp->account = NULL;

/* if this was the last account in a group, delete
Expand All @@ -345,17 +347,14 @@ xaccRemoveAccount (Account *acc)
xaccFreeAccountGroup (grp);
}
}
arr[grp->numAcc] = NULL;
}

/********************************************************************\
\********************************************************************/
int
void
xaccInsertSubAccount( Account *adult, Account *child )
{
int retval;

if (NULL == adult) return -1;
if (NULL == adult) return;

/* if a container for the children doesn't yet exist, add it */
if (NULL == adult->children) {
Expand All @@ -366,42 +365,47 @@ xaccInsertSubAccount( Account *adult, Account *child )
adult->children->parent = adult;

/* allow side-effect of creating a child-less account group */
if (NULL == child) return -1;
if (NULL == child) return;

retval = xaccGroupInsertAccount (adult->children, child);
return retval;
xaccGroupInsertAccount (adult->children, child);
}

/********************************************************************\
\********************************************************************/
int

void
xaccGroupInsertAccount( AccountGroup *grp, Account *acc )
{
int i=-1;
Account **oldAcc;
Account **arr;

if (NULL == grp) return -1;
if (NULL == acc) return -1;
if (NULL == grp) return;
if (NULL == acc) return;

/* If the account is currently in another group, remove it there first.
* Basically, we can't have accounts being in two places at once. */
if (acc->parent) {
xaccRemoveAccount (acc);
}

/* set back-pointer to the accounts parent */
acc->parent = grp;

oldAcc = grp->account;
arr = grp->account;

grp->saved = FALSE;

grp->account = (Account **)_malloc(((grp->numAcc)+2)*sizeof(Account *));

for( i=0; i<(grp->numAcc); i++ ) {
grp->account[i] = oldAcc[i];
grp->account[i] = arr[i];
}
_free(oldAcc);
_free(arr);

grp->account[(grp->numAcc)] = acc;
grp->numAcc++;
grp->account[(grp->numAcc)] = NULL;

return i;
}

/********************************************************************\
Expand Down
4 changes: 2 additions & 2 deletions src/engine/Group.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ void xaccAccountGroupMarkSaved (AccountGroup *grp);
*/
void xaccRemoveAccount (Account *);
void xaccRemoveGroup (AccountGroup *);
int xaccGroupInsertAccount( AccountGroup *grp, Account *acc );
int xaccInsertSubAccount( Account *parent, Account *child );
void xaccGroupInsertAccount( AccountGroup *grp, Account *acc );
void xaccInsertSubAccount( Account *parent, Account *child );

/*
* The xaccGetNumAccounts() subroutine returns the number
Expand Down

0 comments on commit 893f6bb

Please sign in to comment.