mirror of
https://github.com/jarun/nnn.git
synced 2024-11-28 13:51:31 +00:00
Remove some more useless memory allocations
This commit is contained in:
parent
9f6d1cfb33
commit
35ca388e9d
13
noice.c
13
noice.c
|
@ -341,7 +341,7 @@ nextsel(char **run, char **env)
|
||||||
char *
|
char *
|
||||||
readln(void)
|
readln(void)
|
||||||
{
|
{
|
||||||
char ln[LINE_MAX];
|
static char ln[LINE_MAX];
|
||||||
|
|
||||||
timeout(-1);
|
timeout(-1);
|
||||||
echo();
|
echo();
|
||||||
|
@ -351,7 +351,7 @@ readln(void)
|
||||||
noecho();
|
noecho();
|
||||||
curs_set(FALSE);
|
curs_set(FALSE);
|
||||||
timeout(1000);
|
timeout(1000);
|
||||||
return ln[0] ? strdup(ln) : NULL;
|
return ln[0] ? ln : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -567,7 +567,7 @@ redraw(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
browse(const char *ipath, const char *ifilter)
|
browse(char *ipath, char *ifilter)
|
||||||
{
|
{
|
||||||
char newpath[PATH_MAX];
|
char newpath[PATH_MAX];
|
||||||
char *name, *bin, *dir, *tmp, *run, *env;
|
char *name, *bin, *dir, *tmp, *run, *env;
|
||||||
|
@ -661,13 +661,11 @@ nochange:
|
||||||
printprompt("filter: ");
|
printprompt("filter: ");
|
||||||
tmp = readln();
|
tmp = readln();
|
||||||
if (tmp == NULL)
|
if (tmp == NULL)
|
||||||
tmp = xstrdup(ifilter);
|
tmp = ifilter;
|
||||||
/* Check and report regex errors */
|
/* Check and report regex errors */
|
||||||
r = setfilter(&re, tmp);
|
r = setfilter(&re, tmp);
|
||||||
if (r != 0) {
|
if (r != 0)
|
||||||
free(tmp);
|
|
||||||
goto nochange;
|
goto nochange;
|
||||||
}
|
|
||||||
strlcpy(fltr, tmp, sizeof(fltr));
|
strlcpy(fltr, tmp, sizeof(fltr));
|
||||||
DPRINTF_S(fltr);
|
DPRINTF_S(fltr);
|
||||||
/* Save current */
|
/* Save current */
|
||||||
|
@ -705,7 +703,6 @@ nochange:
|
||||||
goto nochange;
|
goto nochange;
|
||||||
}
|
}
|
||||||
mkpath(path, tmp, newpath, sizeof(newpath));
|
mkpath(path, tmp, newpath, sizeof(newpath));
|
||||||
free(tmp);
|
|
||||||
if (canopendir(newpath) == 0) {
|
if (canopendir(newpath) == 0) {
|
||||||
printwarn();
|
printwarn();
|
||||||
goto nochange;
|
goto nochange;
|
||||||
|
|
Loading…
Reference in a new issue