multiprogress.c: Get the `termcap' string after allocating the buffers.
authorMark Wooding <mdw@distorted.org.uk>
Fri, 25 Mar 2022 00:39:47 +0000 (00:39 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Fri, 25 Mar 2022 00:48:50 +0000 (00:48 +0000)
It works better that way, except with GNU `termcap'.

multiprogress.c

index 0594f37..3d4ba8c 100644 (file)
@@ -91,12 +91,12 @@ int progress_init(struct progress_state *progress)
 
 #elif defined(USE_TERMCAP)
 
-  term = getenv("TERM"); if (!term) return (-1);
-  if (tgetent(tty->termbuf, term) < 1) return (-1);
-
   tty->termbuf = malloc(4096); if (!tty->termbuf) return (-1);
   tty->capbuf = malloc(4096); if (!tty->capbuf) return (-1);
 
+  term = getenv("TERM"); if (!term) return (-1);
+  if (tgetent(tty->termbuf, term) < 1) return (-1);
+
   capcur = tty->capbuf;
   tty->cap.cr = tgetstr("cr", &capcur);
   tty->cap.nw = tgetstr("nw", &capcur);