From b259b9100721ba111b74a7fee06b5768c340ad37 Mon Sep 17 00:00:00 2001 From: Joel Rosdahl Date: Mon, 19 Jul 2010 11:52:14 +0200 Subject: [PATCH] Extract common exit code in cleanup.c's traverse_fn() --- cleanup.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/cleanup.c b/cleanup.c index 9e6f0ad5f..e33accae6 100644 --- 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) -- 2.47.3