[grisbi-cvs] [SCM] grisbi branch, master, updated. upstream_version_1_1_1-76-g5d45188

Philippe Delorme nobody at users.sourceforge.net
Sat Jan 19 21:58:13 CET 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grisbi".

The branch, master has been updated
       via  5d451888a8109432cd079e7f8d3494632b5b47a4 (commit)
      from  78646179506933617ab0c9aff5327b66c39bd426 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 5d451888a8109432cd079e7f8d3494632b5b47a4
Author: Philippe Delorme <philippedelorme at users.sourceforge.net>
Date:   Sat Jan 19 21:55:20 2013 +0100

    Clean up in memory management
    
    Removed useless checks for both allocation and freeing

-----------------------------------------------------------------------

Changes:
diff --git a/src/gsb_data_account.c b/src/gsb_data_account.c
index 7816d9d..b1e4f46 100644
--- a/src/gsb_data_account.c
+++ b/src/gsb_data_account.c
@@ -2834,8 +2834,8 @@ void gsb_data_account_colorize_current_balance ( gint account_number )
     if ( gsb_data_account_get_current_balance (account_number).mantissa < 0 )
     {
         string = g_strdup_printf ( "<span color=\"red\">%s</span>", tmpstr );
+        g_free ( tmpstr );
     }
-    g_free ( tmpstr );
 
     if ( !string )
         string = g_strdup ( "" );
diff --git a/src/gsb_data_reconcile.c b/src/gsb_data_reconcile.c
index ec3907e..1d76cdf 100644
--- a/src/gsb_data_reconcile.c
+++ b/src/gsb_data_reconcile.c
@@ -222,15 +222,12 @@ gint gsb_data_reconcile_new ( const gchar *name )
     reconcile = g_malloc0 ( sizeof ( struct_reconcile ));
     if (!reconcile)
     {
-	dialogue_error_memory ();
-	return 0;
+        dialogue_error_memory ();
+        return 0;
     }
 
     reconcile -> reconcile_number = gsb_data_reconcile_max_number () + 1;
-
-    if (name)
-	reconcile -> reconcile_name = my_strdup (name);
-
+    reconcile -> reconcile_name = my_strdup (name);
     reconcile_list = g_list_append ( reconcile_list, reconcile );
 
     return reconcile -> reconcile_number;
diff --git a/src/gsb_data_scheduled.c b/src/gsb_data_scheduled.c
index ae5bc38..a000d55 100644
--- a/src/gsb_data_scheduled.c
+++ b/src/gsb_data_scheduled.c
@@ -808,19 +808,11 @@ gboolean gsb_data_scheduled_set_notes ( gint scheduled_number,
     struct_scheduled *scheduled;
 
     scheduled = gsb_data_scheduled_get_scheduled_by_no ( scheduled_number);
-
     if ( !scheduled )
-	return FALSE;
+        return FALSE;
 
-    if ( scheduled -> notes )
-        g_free ( scheduled -> notes );
-
-    if ( notes
-	 &&
-	 strlen (notes))
-	scheduled -> notes = my_strdup (notes);
-    else
-	scheduled -> notes = NULL;
+    g_free ( scheduled -> notes );
+    scheduled -> notes = my_strdup (notes);
 
     return TRUE;
 }
@@ -925,19 +917,11 @@ gboolean gsb_data_scheduled_set_method_of_payment_content ( gint scheduled_numbe
     struct_scheduled *scheduled;
 
     scheduled = gsb_data_scheduled_get_scheduled_by_no ( scheduled_number);
-
     if ( !scheduled )
-	return FALSE;
-
-    if ( scheduled -> method_of_payment_content )
-        g_free ( scheduled -> method_of_payment_content );
+        return FALSE;
 
-    if ( method_of_payment_content
-	 &&
-	 strlen (method_of_payment_content))
-	scheduled -> method_of_payment_content = my_strdup (method_of_payment_content);
-    else
-	scheduled -> method_of_payment_content = NULL;
+    g_free ( scheduled -> method_of_payment_content );
+    scheduled -> method_of_payment_content = my_strdup (method_of_payment_content);
 
     return TRUE;
 }
@@ -1495,17 +1479,17 @@ gint gsb_data_scheduled_new_scheduled_with_number ( gint scheduled_number )
 
     if ( !scheduled )
     {
-	dialogue_error_memory ();
-	return FALSE;
+        dialogue_error_memory ();
+        return FALSE;
     }
 
     if ( !scheduled_number )
-	scheduled_number = gsb_data_scheduled_get_last_number () + 1;
+        scheduled_number = gsb_data_scheduled_get_last_number () + 1;
 
     scheduled -> scheduled_number = scheduled_number;
 
     scheduled_list = g_slist_append ( scheduled_list,
-				      scheduled );
+            scheduled );
 
     gsb_data_scheduled_save_scheduled_pointer (scheduled);
 
@@ -1585,15 +1569,17 @@ static void _gsb_data_scheduled_free ( struct_scheduled *scheduled )
 {
     if ( ! scheduled )
         return;
-    if ( scheduled -> notes )
-	g_free ( scheduled -> notes );
+
+    g_free ( scheduled -> notes );
+    g_free ( scheduled -> method_of_payment_content );
+
     if ( scheduled -> date )
-	g_date_free ( scheduled -> date );
+        g_date_free ( scheduled -> date );
     if ( scheduled -> limit_date )
-	g_date_free ( scheduled -> limit_date );
-    if ( scheduled -> method_of_payment_content )
-	g_free ( scheduled -> method_of_payment_content );
+        g_date_free ( scheduled -> limit_date );
+
     g_free ( scheduled );
+
     scheduled_buffer[0] = NULL;
     scheduled_buffer[1] = NULL;
     current_scheduled_buffer = 0;
diff --git a/src/gsb_data_transaction.c b/src/gsb_data_transaction.c
index 45954ba..8b3d5ab 100644
--- a/src/gsb_data_transaction.c
+++ b/src/gsb_data_transaction.c
@@ -414,18 +414,18 @@ gboolean gsb_data_transaction_set_transaction_id ( gint transaction_number,
 {
     struct_transaction *transaction;
 
-    transaction = gsb_data_transaction_get_transaction_by_no ( transaction_number);
+    transaction = gsb_data_transaction_get_transaction_by_no ( transaction_number );
 
     if ( !transaction )
-	return FALSE;
+        return FALSE;
 
-    if ( transaction -> transaction_id )
-        g_free ( transaction -> transaction_id );
+    g_free ( transaction -> transaction_id );
 
-    if (transaction_id)
-	transaction -> transaction_id = my_strdup (transaction_id);
+    if ( transaction_id )
+        transaction -> transaction_id = my_strdup ( transaction_id );
     else
-    	transaction -> transaction_id = NULL;
+        transaction -> transaction_id = NULL;
+
     return TRUE;
 }
 
@@ -537,7 +537,6 @@ gboolean gsb_data_transaction_set_date ( gint transaction_number,
 
     if (transaction -> date)
         g_date_free (transaction -> date);
-
     transaction -> date = gsb_date_copy (date);
 
     /* if the transaction is a split, change all the children */
@@ -555,7 +554,6 @@ gboolean gsb_data_transaction_set_date ( gint transaction_number,
 
 	    if (transaction -> date)
             g_date_free (transaction -> date);
-
 	    transaction -> date = gsb_date_copy (date);
 
         /* si l'opération fille est un transfert on regarde si la contre opération est rapprochée
@@ -621,8 +619,7 @@ gboolean gsb_data_transaction_set_value_date ( gint transaction_number,
 	return FALSE;
 
     if (transaction ->  value_date)
-	g_date_free (transaction ->  value_date);
-
+        g_date_free (transaction ->  value_date);
     transaction ->  value_date = gsb_date_copy (date);
 
     /* if the transaction is a split, change all the children */
@@ -639,8 +636,7 @@ gboolean gsb_data_transaction_set_value_date ( gint transaction_number,
 	    transaction = tmp_list -> data;
 
 	    if (transaction ->  value_date)
-		g_date_free (transaction -> value_date);
-
+            g_date_free (transaction -> value_date);
 	    transaction -> value_date = gsb_date_copy (date);
 
 	    tmp_list = tmp_list -> next;
@@ -1331,19 +1327,11 @@ gboolean gsb_data_transaction_set_notes ( gint transaction_number,
     struct_transaction *transaction;
 
     transaction = gsb_data_transaction_get_transaction_by_no ( transaction_number);
-
     if ( !transaction )
-	return FALSE;
-
-    if ( transaction -> notes )
-        g_free ( transaction -> notes );
+        return FALSE;
 
-    if ( notes
-	 &&
-	 strlen (notes))
-	transaction -> notes = my_strdup (notes);
-    else
-	transaction -> notes = NULL;
+    g_free ( transaction -> notes );
+    transaction -> notes = my_strdup ( notes );
 
     return TRUE;
 }
@@ -1446,19 +1434,11 @@ gboolean gsb_data_transaction_set_method_of_payment_content ( gint transaction_n
     struct_transaction *transaction;
 
     transaction = gsb_data_transaction_get_transaction_by_no ( transaction_number);
-
     if ( !transaction )
-	return FALSE;
+        return FALSE;
 
-    if ( transaction -> method_of_payment_content )
-        g_free ( transaction -> method_of_payment_content );
-
-    if ( method_of_payment_content
-	 &&
-	 strlen (method_of_payment_content))
-	transaction -> method_of_payment_content = my_strdup (method_of_payment_content);
-    else
-	transaction -> method_of_payment_content = NULL;
+    g_free ( transaction -> method_of_payment_content );
+    transaction -> method_of_payment_content = my_strdup ( method_of_payment_content );
 
     return TRUE;
 }
@@ -1831,21 +1811,16 @@ gboolean gsb_data_transaction_set_voucher ( gint transaction_number,
 {
     struct_transaction *transaction;
 
-    transaction = gsb_data_transaction_get_transaction_by_no ( transaction_number);
-
+    transaction = gsb_data_transaction_get_transaction_by_no ( transaction_number );
     if ( !transaction )
-	return FALSE;
-
+        return FALSE;
 
-    if ( transaction -> voucher )
-        g_free ( transaction -> voucher );
+    g_free ( transaction -> voucher );
 
-    if ( voucher
-	 &&
-	 strlen (voucher))
-	transaction -> voucher = my_strdup (voucher);
+    if ( voucher && strlen (voucher) )
+        transaction -> voucher = my_strdup ( voucher );
     else
-	transaction -> voucher = g_strdup("");
+        transaction -> voucher = g_strdup ("");
 
     return TRUE;
 }
@@ -1887,19 +1862,11 @@ gboolean gsb_data_transaction_set_bank_references ( gint transaction_number,
     struct_transaction *transaction;
 
     transaction = gsb_data_transaction_get_transaction_by_no ( transaction_number);
-
     if ( !transaction )
-	return FALSE;
+        return FALSE;
 
-    if ( transaction -> bank_references )
-        g_free ( transaction -> bank_references );
-
-    if ( bank_references
-	 &&
-	 strlen (bank_references))
-	transaction -> bank_references = my_strdup (bank_references);
-    else
-	transaction -> bank_references = NULL;
+    g_free ( transaction -> bank_references );
+    transaction -> bank_references = my_strdup ( bank_references );
 
     return TRUE;
 }
@@ -2209,22 +2176,22 @@ static void gsb_data_transaction_free ( struct_transaction *transaction)
 {
     if ( ! transaction )
         return;
+
     gsb_data_account_set_balances_are_dirty ( transaction -> account_number );
-    if ( transaction -> transaction_id )
-        g_free ( transaction -> transaction_id );
-    if ( transaction -> notes )
-        g_free ( transaction -> notes );
-    if ( transaction -> voucher )
-        g_free ( transaction -> voucher );
-    if ( transaction -> bank_references )
-        g_free ( transaction -> bank_references );
+
+    g_free ( transaction -> transaction_id );
+    g_free ( transaction -> notes );
+    g_free ( transaction -> voucher );
+    g_free ( transaction -> bank_references );
+    g_free ( transaction -> method_of_payment_content );
+
     if ( transaction -> date )
         g_date_free ( transaction -> date );
     if ( transaction -> value_date )
         g_date_free ( transaction -> value_date );
-    if ( transaction -> method_of_payment_content )
-        g_free ( transaction -> method_of_payment_content );
+
     g_free ( transaction );
+
     transaction_buffer[0] = NULL;
     transaction_buffer[1] = NULL;
 }


hooks/post-receive
-- 
grisbi


More information about the cvs mailing list