aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.c3
-rw-r--r--thumbs.c9
-rw-r--r--util.c17
3 files changed, 10 insertions, 19 deletions
diff --git a/main.c b/main.c
index 070d419..821f63b 100644
--- a/main.c
+++ b/main.c
@@ -810,8 +810,7 @@ int main(int argc, char **argv)
filename[len-1] = '\0';
check_add_file(filename);
}
- if (filename != NULL)
- free(filename);
+ free(filename);
}
for (i = 0; i < options->filecnt; i++) {
diff --git a/thumbs.c b/thumbs.c
index ea91292..3f13af0 100644
--- a/thumbs.c
+++ b/thumbs.c
@@ -176,8 +176,7 @@ void tns_init(tns_t *tns, const fileinfo_t *files, int cnt, int *sel, win_t *win
dsuffix = "/.cache";
}
if (homedir != NULL) {
- if (cache_dir != NULL)
- free(cache_dir);
+ free(cache_dir);
len = strlen(homedir) + strlen(dsuffix) + 6;
cache_dir = (char*) s_malloc(len);
snprintf(cache_dir, len, "%s%s/sxiv", homedir, dsuffix);
@@ -204,10 +203,8 @@ void tns_free(tns_t *tns)
tns->thumbs = NULL;
}
- if (cache_dir != NULL) {
- free(cache_dir);
- cache_dir = NULL;
- }
+ free(cache_dir);
+ cache_dir = NULL;
}
bool tns_load(tns_t *tns, int n, bool force)
diff --git a/util.c b/util.c
index c7b3bc8..3a5ae9a 100644
--- a/util.c
+++ b/util.c
@@ -198,18 +198,13 @@ char* absolute_path(const char *filename)
goto end;
error:
- if (path != NULL) {
- free(path);
- path = NULL;
- }
+ free(path);
+ path = NULL;
end:
- if (dirname != NULL)
- free(dirname);
- if (cwd != NULL)
- free(cwd);
- if (twd != NULL)
- free(twd);
+ free(dirname);
+ free(cwd);
+ free(twd);
return path;
}
@@ -254,7 +249,7 @@ int r_closedir(r_dir_t *rdir)
rdir->dir = NULL;
}
- if (rdir->d != 0 && rdir->name != NULL) {
+ if (rdir->d != 0) {
free(rdir->name);
rdir->name = NULL;
}