return 0;
}
-static void dentfree(struct entry *dents)
+static void dentfree(void)
{
free(pnamebuf);
free(dents);
/* Should never be null */
if (closedir(dirp) == -1) {
- dentfree(*dents);
+ dentfree();
errexit();
}
char *dir, *tmp;
char *scriptpath = getenv(env_cfg[NNN_SCRIPT]);
+ atexit(dentfree);
+
/* setup first context */
xstrlcpy(g_ctx[0].c_path, ipath, PATH_MAX); /* current directory */
path = g_ctx[0].c_path;
cfg.filtermode ? (presel = FILTER) : (presel = 0);
dents = xrealloc(dents, total_dents * sizeof(struct entry));
- if (dents == NULL)
+ if (!dents)
errexit();
/* Allocate buffer to hold names */
pnamebuf = (char *)xrealloc(pnamebuf, NAMEBUF_INCR);
- if (pnamebuf == NULL) {
- free(dents);
+ if (!pnamebuf)
errexit();
- }
begin:
#ifdef LINUX_INOTIFY
r = mkpath(path, dents[cur].name, newpath);
appendfpath(newpath, r);
writecp(pcopybuf, copybufpos - 1);
-
- dentfree(dents);
return;
}
goto nochange;
}
}
-
- dentfree(dents);
return;
case SEL_QUITCTX:
fd = cfg.curctx;
setdirwatch();
goto begin;
}
-
- dentfree(dents);
return;
default:
if (xlines != LINES || xcols != COLS) {