]> diplodocus.org Git - nmh/blobdiff - sbr/fmt_scan.c
Corrected comment: whom(1) does not use context_foil().
[nmh] / sbr / fmt_scan.c
index cb29b72cb1460cb669116ccfbc04b3b115e73f69..f9aee54b0d2bd866f23bb4075424c58ee025722e 100644 (file)
@@ -247,9 +247,9 @@ static void
 cpstripped (charstring_t dest, size_t max, char *str)
 {
     static bool deja_vu;
-    static char *oddchar;
+    static char oddchar[MB_LEN_MAX * 2];
     static size_t oddlen;
-    static char *spacechar;
+    static char spacechar[MB_LEN_MAX * 2];
     static size_t spacelen;
     char *end;
     bool squash;
@@ -259,19 +259,12 @@ cpstripped (charstring_t dest, size_t max, char *str)
     int w;
 
     if (!deja_vu) {
-        size_t two;
-
         deja_vu = true;
 
-        two = MB_CUR_MAX * 2; /* Varies at run-time. */
-
-        oddchar = mh_xmalloc(two);
-        oddlen = wcstombs(oddchar, L"?", two);
+        oddlen = wcstombs(oddchar, L"?", sizeof oddchar);
         assert(oddlen > 0);
-
         assert(wcwidth(L' ') == 1); /* Need to pad in ones. */
-        spacechar = mh_xmalloc(two);
-        spacelen = wcstombs(spacechar, L" ", two);
+        spacelen = wcstombs(spacechar, L" ", sizeof spacechar);
         assert(spacelen > 0);
     }
 
@@ -1155,7 +1148,11 @@ fmt_scan (struct format *format, charstring_t scanlp, int width, int *dat,
                               comp->c_mn will be run through
                               FT_LS_ADDR, which will strip off any
                               pers name. */
-                           free (comp->c_text);
+                           /* NB: We remove the call to free() here
+                              because it interferes with the buffer
+                              management in scansbr.c.  Revisit this
+                              when we clean up memory handling */
+                           /* free (comp->c_text); */
                            comp->c_text = str = strdup (mn->m_text);
                            comp->c_mn = mn;
                        }