r15639 - gnucash/trunk/src - Simplify function parameters.

David Hampton hampton at cvs.gnucash.org
Wed Feb 21 01:59:52 EST 2007


Author: hampton
Date: 2007-02-21 01:59:50 -0500 (Wed, 21 Feb 2007)
New Revision: 15639
Trac: http://svn.gnucash.org/trac/changeset/15639

Modified:
   gnucash/trunk/src/engine/Account.c
   gnucash/trunk/src/engine/Account.h
   gnucash/trunk/src/engine/Group.c
   gnucash/trunk/src/gnome-utils/gnc-tree-view-account.c
Log:
Simplify function parameters.

Modified: gnucash/trunk/src/engine/Account.c
===================================================================
--- gnucash/trunk/src/engine/Account.c	2007-02-21 02:05:55 UTC (rev 15638)
+++ gnucash/trunk/src/engine/Account.c	2007-02-21 06:59:50 UTC (rev 15639)
@@ -996,20 +996,20 @@
 
 
 int
-xaccAccountOrder (const Account **aa, const Account **ab) 
+xaccAccountOrder (const Account *aa, const Account *ab) 
 {
   char *da, *db;
   char *endptr = NULL;
   int ta, tb, result;
   long la, lb;
 
-  if ( (*aa) && !(*ab) ) return -1;
-  if ( !(*aa) && (*ab) ) return +1;
-  if ( !(*aa) && !(*ab) ) return 0;
+  if ( aa && !ab ) return -1;
+  if ( !aa && ab ) return +1;
+  if ( !aa && !ab ) return 0;
 
   /* sort on accountCode strings */
-  da = (*aa)->accountCode;
-  db = (*ab)->accountCode;
+  da = aa->accountCode;
+  db = ab->accountCode;
 
   /* If accountCodes are both base 36 integers do an integer sort */
   la = strtoul (da, &endptr, 36);
@@ -1036,24 +1036,30 @@
   }
 
   /* otherwise, sort on account type */
-  ta = (*aa)->type;
-  tb = (*ab)->type;
+  ta = aa->type;
+  tb = ab->type;
   ta = revorder[ta];
   tb = revorder[tb];
   if (ta < tb) return -1;
   if (ta > tb) return +1;
 
   /* otherwise, sort on accountName strings */
-  da = (*aa)->accountName;
-  db = (*ab)->accountName;
+  da = aa->accountName;
+  db = ab->accountName;
   result = safe_utf8_collate(da, db);
   if (result)
     return result;
 
   /* guarantee a stable sort */
-  return guid_compare (&((*aa)->inst.entity.guid), &((*ab)->inst.entity.guid));
+  return guid_compare (&(aa->inst.entity.guid), &(ab->inst.entity.guid));
 }
 
+static int
+qof_xaccAccountOrder (const Account **aa, const Account **ab)
+{
+  return xaccAccountOrder(*aa, *ab);
+}
+
 /********************************************************************\
 \********************************************************************/
 
@@ -2717,7 +2723,7 @@
     { NULL },
   };
 
-  qof_class_register (GNC_ID_ACCOUNT, (QofSortFunc) xaccAccountOrder, params);
+  qof_class_register (GNC_ID_ACCOUNT, (QofSortFunc) qof_xaccAccountOrder, params);
 
   return qof_object_register (&account_object_def);
 }

Modified: gnucash/trunk/src/engine/Account.h
===================================================================
--- gnucash/trunk/src/engine/Account.h	2007-02-21 02:05:55 UTC (rev 15638)
+++ gnucash/trunk/src/engine/Account.h	2007-02-21 06:59:50 UTC (rev 15639)
@@ -188,7 +188,7 @@
  *    the account codes are compared, and if these are equal, then 
  *    account types, and, if these are equal, the account names.
  */
-int xaccAccountOrder (const Account **account_1, const Account **account_2);
+int xaccAccountOrder (const Account *account_1, const Account *account_2);
 
 /** @} */
 

Modified: gnucash/trunk/src/engine/Group.c
===================================================================
--- gnucash/trunk/src/engine/Group.c	2007-02-21 02:05:55 UTC (rev 15638)
+++ gnucash/trunk/src/engine/Group.c	2007-02-21 06:59:50 UTC (rev 15639)
@@ -421,12 +421,9 @@
 static int
 group_sort_helper (gconstpointer a, gconstpointer b)
 {
-  const Account *aa = (const Account *) a;
-  const Account *bb = (const Account *) b;
-
-  /* xaccAccountOrder returns > 1 if aa should come after bb.
+  /* xaccAccountOrder returns > 1 if a should come after b.
    * This funciton is building a reversed list. */
-  return xaccAccountOrder (&aa, &bb);
+  return xaccAccountOrder ((const Account *) a, (const Account *) b);
 }
 
 static void

Modified: gnucash/trunk/src/gnome-utils/gnc-tree-view-account.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-view-account.c	2007-02-21 02:05:55 UTC (rev 15638)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-view-account.c	2007-02-21 06:59:50 UTC (rev 15639)
@@ -286,7 +286,7 @@
   result = safe_utf8_collate(str1, str2);
   if (result != 0)
     return result;
-  return xaccAccountOrder(&account1, &account2);
+  return xaccAccountOrder(account1, account2);
 }
 
 static gint
@@ -300,7 +300,7 @@
   sort_cb_setup (f_model, f_iter_a, f_iter_b, &account_a, &account_b);
 
   /* Default ordering uses this column first. */
-  return xaccAccountOrder(&account_a, &account_b);
+  return xaccAccountOrder(account_a, account_b);
 }
 
 static gint
@@ -325,7 +325,7 @@
   result = gnc_numeric_compare(balance_a, balance_b);
   if (result != 0)
     return result;
-  return xaccAccountOrder(&account_a, &account_b);
+  return xaccAccountOrder(account_a, account_b);
 }
 
 static gint
@@ -408,7 +408,7 @@
     return -1;
   else if (flag_a < flag_b)
     return 1;
-  return xaccAccountOrder(&account_a, &account_b);
+  return xaccAccountOrder(account_a, account_b);
 }
 
 static gint
@@ -434,7 +434,7 @@
   result = gnc_numeric_compare(b1, b2);
   if (result != 0)
     return result;
-  return xaccAccountOrder((const Account **)&acct1, (const Account **)&acct2);
+  return xaccAccountOrder(acct1, acct2);
 }
 
 static gint



More information about the gnucash-changes mailing list