From: Emmanuel Rodriguez Date: Tue, 16 Jun 2009 21:13:15 +0000 (+0200) Subject: Time variables (GTimeVal) are declared on the stack. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=41be4553778730ff53e610d60218ab142b51cbdc;p=libchamplain 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. --- 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_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);