X-Git-Url: http://pileus.org/git/?p=grits;a=blobdiff_plain;f=src%2Fdata.c;h=ab373114c6b0f3e3529f2208d1d1d8bc53860951;hp=7c43138a5c5f51863454ac2f78b6950dee137f57;hb=93c853165104b5119e17be07e325f9097a5ebdb3;hpb=99863849923de021148ebf371aaeab427ae139e1 diff --git a/src/data.c b/src/data.c index 7c43138..ab37311 100644 --- a/src/data.c +++ b/src/data.c @@ -1,3 +1,20 @@ +/* + * Copyright (C) 2009 Andy Spencer + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #include #include #include @@ -53,11 +70,17 @@ void cache_file(char *base, char *path, AWeatherCacheDoneCallback callback, gpoi else if (g_file_get_size(src) != g_file_get_size(dst)) g_message("Caching file: sizes mismatch - %lld != %lld", g_file_get_size(src), g_file_get_size(dst)); - else - return callback(local, user_data); + else { + callback(local, user_data); + g_free(local); + g_free(url); + return; + } - if (!g_file_test(g_path_get_dirname(local), G_FILE_TEST_IS_DIR)) - g_mkdir_with_parents(g_path_get_dirname(local), 0755); + char *dir = g_path_get_dirname(local); + if (!g_file_test(dir, G_FILE_TEST_IS_DIR)) + g_mkdir_with_parents(dir, 0755); + g_free(dir); cache_file_end_t *info = g_malloc0(sizeof(cache_file_end_t)); info->callback = callback; info->src = url;