]> err.no Git - libchamplain/commitdiff
Time variables (GTimeVal) are declared on the stack.
authorEmmanuel Rodriguez <emmanuel.rodriguez@gmail.com>
Tue, 16 Jun 2009 21:13:15 +0000 (23:13 +0200)
committerPierre-Luc Beaudoin <pierre-luc@pierlux.com>
Tue, 23 Jun 2009 16:35:40 +0000 (12:35 -0400)
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

index 9669ce81881d27b8e2ccbea0e1fe3cfac0fd1617..99a90b20c5fa1546e823573c8f741e66a5146ead 100644 (file)
@@ -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_FILE_QUERY_INFO_NONE, NULL, NULL);
 
-      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,
           NULL);
 
       g_object_unref (file);
       g_object_unref (info);
-      g_free (now);
 
       champlain_tile_set_state (tile, CHAMPLAIN_STATE_DONE);
       g_object_unref (tile);