[libchamplain] Time variables (GTimeVal) are declared on the stack.

commit 41be4553778730ff53e610d60218ab142b51cbdc
Author: Emmanuel Rodriguez <emmanuel rodriguez gmail com>
Date:   Tue Jun 16 23:13:15 2009 +0200

    Time variables (GTimeVal) are declared on the stack.
    There's no need to declare them with g_new0 and to free them in the same
    funciton. Furthermore, the allocation could fail and the code assumes that all
    went fine. If the variable is allocated on the stack there's no need to check
    if the allocation was succesful.

 champlain/champlain-network-map-source.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/champlain/champlain-network-map-source.c b/champlain/champlain-network-map-source.c
index 9669ce8..99a90b2 100644
--- a/champlain/champlain-network-map-source.c
+++ b/champlain/champlain-network-map-source.c
@@ -450,20 +450,19 @@ file_loaded_cb (SoupSession *session,
       /* Since we are updating the cache, we can assume that the directories
        * exists */
-      GTimeVal *now = g_new0 (GTimeVal, 1);
+      GTimeVal now = {0, };
       file = g_file_new_for_path (filename);
       info = g_file_query_info (file, G_FILE_ATTRIBUTE_TIME_MODIFIED,
-      g_get_current_time (now);
-      g_file_info_set_modification_time (info, now);
+      g_get_current_time (&now);
+      g_file_info_set_modification_time (info, &now);
       g_file_set_attributes_from_info (file, info, G_FILE_QUERY_INFO_NONE, NULL,
       g_object_unref (file);
       g_object_unref (info);
-      g_free (now);
       champlain_tile_set_state (tile, CHAMPLAIN_STATE_DONE);
       g_object_unref (tile);

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]