[Gnucash-changes] Minor code simplification from Chris Shoemaker.

David Hampton hampton at cvs.gnucash.org
Thu Oct 13 23:54:00 EDT 2005


Log Message:
-----------
Minor code simplification from Chris Shoemaker.  Some line wrap fixes
and comments.

Tags:
----
gnucash-gnome2-dev

Modified Files:
--------------
    gnucash/src/backend/file:
        gnc-account-xml-v2.c
    gnucash/src/engine:
        qofbook.c
    gnucash/src/report/report-gnome:
        gnc-plugin-page-report.c

Revision Data
-------------
Index: gnc-account-xml-v2.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/backend/file/gnc-account-xml-v2.c,v
retrieving revision 1.13.4.5
retrieving revision 1.13.4.6
diff -Lsrc/backend/file/gnc-account-xml-v2.c -Lsrc/backend/file/gnc-account-xml-v2.c -u -r1.13.4.5 -r1.13.4.6
--- src/backend/file/gnc-account-xml-v2.c
+++ src/backend/file/gnc-account-xml-v2.c
@@ -327,14 +327,9 @@
 account_slots_handler (xmlNodePtr node, gpointer act_pdata)
 {
     struct account_pdata *pdata = act_pdata;
-    gboolean success;
 
-    success = dom_tree_to_kvp_frame_given
-      (node, xaccAccountGetSlots (pdata->account));
-
-    g_return_val_if_fail(success, FALSE);
-    
-    return TRUE;
+    return dom_tree_to_kvp_frame_given
+        (node, xaccAccountGetSlots (pdata->account));
 }
 
 static gboolean
Index: qofbook.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/qofbook.c,v
retrieving revision 1.10.2.8
retrieving revision 1.10.2.9
diff -Lsrc/engine/qofbook.c -Lsrc/engine/qofbook.c -u -r1.10.2.8 -r1.10.2.9
--- src/engine/qofbook.c
+++ src/engine/qofbook.c
@@ -68,9 +68,10 @@
 {
   if (!book) return;
 
-  book->hash_of_collections = g_hash_table_new_full(g_str_hash, g_str_equal, 
-						    gnc_string_cache_remove,
-						    coll_destroy);
+  book->hash_of_collections = g_hash_table_new_full(
+      g_str_hash, g_str_equal,
+      (GDestroyNotify)gnc_string_cache_remove,  /* key_destroy_func   */
+      coll_destroy);                            /* value_destroy_func */
 
   qof_instance_init (&book->inst, QOF_ID_BOOK, book);
 
@@ -116,7 +117,7 @@
   book->shutting_down = TRUE;
   gnc_engine_force_event (&book->inst.entity, GNC_EVENT_DESTROY);
 
-  /* Call the list of finalizers, let them do thier thing. 
+  /* Call the list of finalizers, let them do their thing.
    * Do this before tearing into the rest of the book.
    */
   g_hash_table_foreach (book->data_table_finalizers, book_final, book);
@@ -124,7 +125,9 @@
   qof_object_book_end (book);
 
   g_hash_table_destroy (book->data_table_finalizers);
+  book->data_table_finalizers = NULL;
   g_hash_table_destroy (book->data_tables);
+  book->data_tables = NULL;
 
   qof_instance_release (&book->inst);
 
@@ -239,13 +242,12 @@
   if (!book || !entity_type) return NULL;
 
   col = g_hash_table_lookup (book->hash_of_collections, entity_type);
-  if (col) return col;
-
-  col = qof_collection_new (entity_type);
-
-  g_hash_table_insert (book->hash_of_collections,
-		       gnc_string_cache_insert((gpointer) entity_type), col);
-                                                                                
+  if (!col) {
+      col = qof_collection_new (entity_type);
+      g_hash_table_insert(
+          book->hash_of_collections,
+          gnc_string_cache_insert((gpointer) entity_type), col);
+  }
   return col;
 }
 
Index: gnc-plugin-page-report.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/report/report-gnome/Attic/gnc-plugin-page-report.c,v
retrieving revision 1.1.2.20
retrieving revision 1.1.2.21
diff -Lsrc/report/report-gnome/gnc-plugin-page-report.c -Lsrc/report/report-gnome/gnc-plugin-page-report.c -u -r1.1.2.20 -r1.1.2.21
--- src/report/report-gnome/gnc-plugin-page-report.c
+++ src/report/report-gnome/gnc-plugin-page-report.c
@@ -121,7 +121,9 @@
         SCM          initial_report; 
         GNCOptionDB  * initial_odb;
         SCM          name_change_cb_id;
-        
+
+        /* keep a list of edited reports so that we can destroy them when
+         * the window is closed. */
         SCM          edited_reports;
 
         /* This is set to mark the fact that we need to reload the html */
@@ -779,7 +781,8 @@
 }
 
 void
-gnc_plugin_page_report_remove_edited_report(GncPluginPageReportPrivate * win, SCM report)
+gnc_plugin_page_report_remove_edited_report(GncPluginPageReportPrivate * win,
+                                            SCM report)
 { 
         SCM new_edited = scm_delete(win->edited_reports, report);
         scm_gc_unprotect_object(win->edited_reports);
@@ -788,7 +791,8 @@
 }
 
 void
-gnc_plugin_page_report_add_edited_report(GncPluginPageReportPrivate * win, SCM report)
+gnc_plugin_page_report_add_edited_report(GncPluginPageReportPrivate * win,
+                                         SCM report)
 {
         SCM new_edited = scm_cons(report, win->edited_reports);
         scm_gc_unprotect_object(win->edited_reports);


More information about the gnucash-changes mailing list