]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Extract common exit code in cleanup.c's traverse_fn()
authorJoel Rosdahl <joel@rosdahl.net>
Mon, 19 Jul 2010 09:52:14 +0000 (11:52 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Mon, 19 Jul 2010 09:52:14 +0000 (11:52 +0200)
cleanup.c

index 9e6f0ad5f9cf33d5ac1eb810df1215cc228006e1..e33accae6db1de10cc113f25d04fe5f72b5d2875 100644 (file)
--- a/cleanup.c
+++ b/cleanup.c
@@ -67,21 +67,17 @@ static void traverse_fn(const char *fname, struct stat *st)
 
        p = basename(fname);
        if (strcmp(p, "stats") == 0) {
-               free(p);
-               return;
+               goto out;
        }
 
        if (strstr(p, ".tmp.") != NULL) {
                /* delete any tmp files older than 1 hour */
                if (st->st_mtime + 3600 < time(NULL)) {
                        unlink(fname);
-                       free(p);
-                       return;
+                       goto out;
                }
        }
 
-       free(p);
-
        if (num_files == allocated) {
                allocated = 10000 + num_files*2;
                files = (struct files **)x_realloc(
@@ -95,6 +91,9 @@ static void traverse_fn(const char *fname, struct stat *st)
        cache_size += files[num_files]->size;
        files_in_cache++;
        num_files++;
+
+out:
+       free(p);
 }
 
 static void delete_file(const char *path, size_t size)