diff options
author | Arun Prakash Jana <engineerarun@gmail.com> | 2018-10-28 00:20:39 +0530 |
---|---|---|
committer | Arun Prakash Jana <engineerarun@gmail.com> | 2018-10-28 00:20:39 +0530 |
commit | 89bc0b37385897652e9d5198da0b160a7e718f8c (patch) | |
tree | 31e54e158e123c55542652c2af885a9382b95eea | |
parent | 134ee92f43029ac3c5dad630e48d6eb160e6a52e (diff) | |
download | nnn-89bc0b37385897652e9d5198da0b160a7e718f8c.tar.gz |
More redundant check removal
-rw-r--r-- | nnn.c | 22 |
1 files changed, 9 insertions, 13 deletions
@@ -460,7 +460,7 @@ static void *xrealloc(void *pcur, size_t len) static void *pmem; pmem = realloc(pcur, len); - if (!pmem && pcur) + if (!pmem) free(pcur); return pmem; @@ -2081,6 +2081,12 @@ static int sum_sizes(const char *fpath, const struct stat *sb, return 0; } +static void dentfree(struct entry *dents) +{ + free(pnamebuf); + free(dents); +} + static int dentfill(char *path, struct entry **dents, int (*filter)(regex_t *, char *), regex_t *re) { @@ -2238,22 +2244,13 @@ static int dentfill(char *path, struct entry **dents, /* Should never be null */ if (closedir(dirp) == -1) { - if (*dents) { - free(pnamebuf); - free(*dents); - } + dentfree(*dents); errexit(); } return n; } -static void dentfree(struct entry *dents) -{ - free(pnamebuf); - free(dents); -} - /* Return the position of the matching entry or 0 otherwise */ static int dentfind(struct entry *dents, const char *fname, int n) { @@ -2887,8 +2884,7 @@ nochange: mkpath(path, dents[cur].name, newpath, PATH_MAX); if (lstat(newpath, &sb) == -1) { - if (dents) - dentfree(dents); + dentfree(dents); errexit(); } |