mirror of
https://github.com/jarun/nnn.git
synced 2024-11-28 13:51:31 +00:00
More redundant check removal
This commit is contained in:
parent
134ee92f43
commit
89bc0b3738
22
nnn.c
22
nnn.c
|
@ -460,7 +460,7 @@ static void *xrealloc(void *pcur, size_t len)
|
||||||
static void *pmem;
|
static void *pmem;
|
||||||
|
|
||||||
pmem = realloc(pcur, len);
|
pmem = realloc(pcur, len);
|
||||||
if (!pmem && pcur)
|
if (!pmem)
|
||||||
free(pcur);
|
free(pcur);
|
||||||
|
|
||||||
return pmem;
|
return pmem;
|
||||||
|
@ -2081,6 +2081,12 @@ static int sum_sizes(const char *fpath, const struct stat *sb,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void dentfree(struct entry *dents)
|
||||||
|
{
|
||||||
|
free(pnamebuf);
|
||||||
|
free(dents);
|
||||||
|
}
|
||||||
|
|
||||||
static int dentfill(char *path, struct entry **dents,
|
static int dentfill(char *path, struct entry **dents,
|
||||||
int (*filter)(regex_t *, char *), regex_t *re)
|
int (*filter)(regex_t *, char *), regex_t *re)
|
||||||
{
|
{
|
||||||
|
@ -2238,22 +2244,13 @@ static int dentfill(char *path, struct entry **dents,
|
||||||
|
|
||||||
/* Should never be null */
|
/* Should never be null */
|
||||||
if (closedir(dirp) == -1) {
|
if (closedir(dirp) == -1) {
|
||||||
if (*dents) {
|
dentfree(*dents);
|
||||||
free(pnamebuf);
|
|
||||||
free(*dents);
|
|
||||||
}
|
|
||||||
errexit();
|
errexit();
|
||||||
}
|
}
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dentfree(struct entry *dents)
|
|
||||||
{
|
|
||||||
free(pnamebuf);
|
|
||||||
free(dents);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return the position of the matching entry or 0 otherwise */
|
/* Return the position of the matching entry or 0 otherwise */
|
||||||
static int dentfind(struct entry *dents, const char *fname, int n)
|
static int dentfind(struct entry *dents, const char *fname, int n)
|
||||||
{
|
{
|
||||||
|
@ -2887,8 +2884,7 @@ nochange:
|
||||||
mkpath(path, dents[cur].name, newpath, PATH_MAX);
|
mkpath(path, dents[cur].name, newpath, PATH_MAX);
|
||||||
|
|
||||||
if (lstat(newpath, &sb) == -1) {
|
if (lstat(newpath, &sb) == -1) {
|
||||||
if (dents)
|
dentfree(dents);
|
||||||
dentfree(dents);
|
|
||||||
errexit();
|
errexit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue