[grisbi-cvs] [SCM] grisbi branch, master, updated. upstream_version_0_9_3-22-g4083f94

Philippe Delorme nobody at users.sourceforge.net
Wed Aug 31 19:54:37 CEST 2011


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  4083f94c3c67db6064623db7e7f6216f73a5fe8d (commit)
       via  161090474b63b3945fbe1138813614bf3539aae2 (commit)
      from  834d016e452a13b101ff43b670e08559684f1138 (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 4083f94c3c67db6064623db7e7f6216f73a5fe8d
Author: Philippe Delorme <philippedelorme at users.sourceforge.net>
Date:   Wed Aug 31 19:52:46 2011 +0200

    Fixed memory leaks

commit 161090474b63b3945fbe1138813614bf3539aae2
Author: Philippe Delorme <philippedelorme at users.sourceforge.net>
Date:   Wed Aug 31 19:34:39 2011 +0200

    Remove useless NULL checks

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

Changes:
diff --git a/src/utils_dates.c b/src/utils_dates.c
index a9e934c..5dc3d60 100644
--- a/src/utils_dates.c
+++ b/src/utils_dates.c
@@ -116,8 +116,7 @@ gchar *gsb_date_today ( void )
  * */
 void gsb_date_set_last_date ( const gchar *date )
 {
-    if ( last_date ) 
-        g_free ( last_date );
+    g_free ( last_date );
     last_date = my_strdup (date);
 }
 
@@ -132,8 +131,7 @@ void gsb_date_set_last_date ( const gchar *date )
  * */
 void gsb_date_free_last_date ( void )
 {
-    if ( last_date ) 
-        g_free ( last_date );
+    g_free ( last_date );
     last_date = NULL;
 }
 
@@ -325,10 +323,10 @@ gboolean gsb_date_check_entry ( GtkWidget *entry )
  */
 GDate *gsb_parse_date_string ( const gchar *date_string )
 {
-    GDate *date;
+    GDate *date = NULL;
     GRegex *date_regex;
-    gchar **date_tokens;
-    gchar **tab_date;
+    gchar **date_tokens = NULL;
+    gchar **tab_date = NULL;
     int num_tokens, num_fields;
     int i, j;
 
@@ -352,12 +350,12 @@ GDate *gsb_parse_date_string ( const gchar *date_string )
         {
             /* big problem */
             alert_debug ( DATE_STRING_KEY );
-            return NULL;
+            goto invalid;
         }
     }
 
     if ( ! g_regex_match ( date_regex, date_string, 0, NULL ) )
-        return NULL;
+        goto invalid;
 
     tab_date = g_regex_split ( date_regex, date_string, 0 );
 
@@ -422,11 +420,15 @@ GDate *gsb_parse_date_string ( const gchar *date_string )
     if ( ! g_date_valid ( date ) )
         goto invalid;
 
+    g_strfreev ( tab_date );
+    g_strfreev ( date_tokens );
     return date;
 
 invalid:
-    g_date_free ( date );
+    if ( date )
+        g_date_free ( date );
     g_strfreev ( tab_date );
+    g_strfreev ( date_tokens );
     return NULL;
 }
 
@@ -615,25 +617,25 @@ gchar *gsb_date_get_format_date ( void )
 
 
 /**
- * set the format of date.
- * 
- * */
+ * Set the format of date. If given format is not valid, the format
+ * value is set to NULL. Since the format is supposed to change, 
+ * the last date entry is erased.
+ *
+ * \param format_date the new format to apply
+ *
+ * \return
+ */
 void gsb_date_set_format_date ( const gchar *format_date )
 {
-    if ( format && strlen ( format ) )
-        g_free ( format );
-
-    if ( format_date == NULL )
-        format = NULL;
-    else if ( strcmp ( format_date, "%d/%m/%Y" ) == 0 )
-        format = g_strdup ( "%d/%m/%Y" );
-    else if ( strcmp ( format_date, "%m/%d/%Y" ) == 0 )
-        format = g_strdup ( "%m/%d/%Y" );
-    else
-        format = NULL;
+    g_free ( format );
+    format = NULL;
+
+    if ( format_date && 
+            ( strcmp ( format_date, "%d/%m/%Y" ) == 0
+           || strcmp ( format_date, "%m/%d/%Y" ) == 0 ) )
+        format = g_strdup ( format_date );
 
-    if ( last_date )
-        g_free ( last_date );
+    g_free ( last_date );
     last_date = NULL;
 }
 


hooks/post-receive
-- 
grisbi


More information about the cvs mailing list