]> Sergey Matveev's repositories - nnn.git/commitdiff
malloc() mem those persist through program runtime
authorArun Prakash Jana <engineerarun@gmail.com>
Fri, 5 Nov 2021 02:20:48 +0000 (07:50 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Fri, 5 Nov 2021 02:29:40 +0000 (07:59 +0530)
At exit, the OS should reclaim all the memory, so no explicit free() required.

src/nnn.c

index 2a2627a2fba3abe697fe76dcc400e9efdc58bac9..1028906a013681b54ff2b8bae44be33ede7b1d07 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -6560,9 +6560,7 @@ static bool cdprep(char *lastdir, char *lastname, char *path, char *newpath)
 
 static bool browse(char *ipath, const char *session, int pkey)
 {
-       char newpath[PATH_MAX] __attribute__ ((aligned)),
-            rundir[PATH_MAX] __attribute__ ((aligned)),
-            runfile[NAME_MAX + 1] __attribute__ ((aligned));
+       char *newpath = malloc(PATH_MAX), *rundir = malloc(PATH_MAX), *runfile = malloc(NAME_MAX + 1);
        char *path, *lastdir, *lastname, *dir, *tmp;
        pEntry pent;
        enum action sel;
@@ -6722,7 +6720,7 @@ nochange:
 
                /* If STDIN is no longer a tty (closed) we should exit */
                if (!isatty(STDIN_FILENO) && !g_state.picker)
-                       return EXIT_FAILURE;
+                       return EXIT_FAILURE; // NOLINT
 
                sel = nextsel(presel);
                if (presel)