Just had a play with this newfangled `valgrind' memory debugger
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Fri, 23 Aug 2002 14:02:01 +0000 (14:02 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Fri, 23 Aug 2002 14:02:01 +0000 (14:02 +0000)
thingy, which seems moderately cool and has reported a few very
small memory leaks. Now apparently fixed.

git-svn-id: svn://svn.tartarus.org/sgt/halibut@1863 cda61777-01e9-0310-a592-d414129be87e

bk_text.c
bk_xhtml.c
input.c

index b682b42..1c8cfb9 100644 (file)
--- a/bk_text.c
+++ b/bk_text.c
@@ -313,7 +313,14 @@ void text_backend(paragraph *sourceform, keywordlist *keywords,
      * Tidy up
      */
     fclose(fp);
-    sfree(conf.bullet.text);
+    {
+       int i;
+       sfree(conf.achapter.number_suffix);
+       for (i = 0; i < conf.nasect; i++)
+           sfree(conf.asect[i].number_suffix);
+       sfree(conf.asect);
+       sfree(conf.bullet.text);
+    }
 }
 
 /*
index 22173d5..edab934 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <assert.h>
 #include "halibut.h"
 
@@ -675,6 +676,13 @@ void xhtml_backend(paragraph *sourceform, keywordlist *in_keywords,
     }
     ientry->backend_data = NULL;
   }
+  {
+    int i;
+    sfree(conf.fchapter.number_suffix);
+    for (i = 0; i < conf.nfsect; i++)
+      sfree(conf.fsect[i].number_suffix);
+    sfree(conf.fsect);
+  }
 }
 
 static int xhtml_para_level(paragraph *p)
diff --git a/input.c b/input.c
index 2e0dabf..d4ecaeb 100644 (file)
--- a/input.c
+++ b/input.c
@@ -547,7 +547,7 @@ static void read_file(paragraph ***ret, input *in, indexdata *idx) {
        }
        already = FALSE;
        if (t.type == tok_eof)
-           return;
+           break;
 
        /*
         * Parse code paragraphs separately.
@@ -1181,6 +1181,11 @@ static void read_file(paragraph ***ret, input *in, indexdata *idx) {
        stk_free(parsestk);
        addpara(par, ret);
     }
+
+    /*
+     * We break to here rather than returning, because otherwise
+     * this cleanup doesn't happen.
+     */
     dtor(t);
     macrocleanup(macros);
 }