diff --git a/src/csync.c b/src/csync.c index 89683aabc..78b1c1373 100644 --- a/src/csync.c +++ b/src/csync.c @@ -699,10 +699,7 @@ static void _tree_destructor(void *data) { csync_file_stat_t *freedata = NULL; freedata = (csync_file_stat_t *) data; - SAFE_FREE(freedata->md5); - SAFE_FREE(freedata->destpath); - SAFE_FREE(freedata->error_string); - SAFE_FREE(freedata); + csync_file_stat_free(freedata); } static int _merge_and_write_statedb(CSYNC *ctx) { @@ -1226,4 +1223,14 @@ int csync_abort_requested(CSYNC *ctx) } } +void csync_file_stat_free(csync_file_stat_t *st) +{ + if (st) { + SAFE_FREE(st->md5); + SAFE_FREE(st->error_string); + SAFE_FREE(st->destpath); + SAFE_FREE(st); + } +} + /* vim: set ts=8 sw=2 et cindent: */ diff --git a/src/csync_private.h b/src/csync_private.h index 70d117012..1a177eb50 100644 --- a/src/csync_private.h +++ b/src/csync_private.h @@ -198,6 +198,8 @@ __attribute__ ((packed)) #endif ; +void csync_file_stat_free(csync_file_stat_t *st); + /* * context for the treewalk function */ diff --git a/src/csync_update.c b/src/csync_update.c index ee99cd458..4080dd61a 100644 --- a/src/csync_update.c +++ b/src/csync_update.c @@ -230,8 +230,7 @@ out: } ctx->current_fs = st; - if( tmp) SAFE_FREE(tmp->md5); - SAFE_FREE(tmp); + csync_file_stat_free(tmp); st->inode = fs->inode; st->mode = fs->mode; st->size = fs->size; @@ -305,10 +304,8 @@ int csync_walker(CSYNC *ctx, const char *file, const csync_vio_file_stat_t *fs, if( !st ) { return 0; } - SAFE_FREE(st->md5); - SAFE_FREE(st->destpath); - SAFE_FREE(st->error_string); - SAFE_FREE(st); + csync_file_stat_free(st); + st = NULL; type = CSYNC_FTW_TYPE_SKIP; break;