]> granicus.if.org Git - yasm/commitdiff
Add DO_FREE #defined constant to allow disabling of deallocation for speed.
authorPeter Johnson <peter@tortall.net>
Mon, 20 Jan 2003 03:52:14 +0000 (03:52 -0000)
committerPeter Johnson <peter@tortall.net>
Mon, 20 Jan 2003 03:52:14 +0000 (03:52 -0000)
svn path=/trunk/yasm/; revision=821

frontends/yasm/yasm.c
src/main.c

index b4484ef96cd564c645dc47a6e201488a05bf66bf..ac8422d12645b542f1ad6ffc4e5c2b6d66ae8ba1 100644 (file)
@@ -469,39 +469,49 @@ open_obj(const char *mode)
     return obj;
 }
 
+/* Define DO_FREE to 1 to enable deallocation of all data structures.
+ * Useful for detecting memory leaks, but slows down execution unnecessarily
+ * (as the OS will free everything we miss here).
+ */
+#define DO_FREE                1
+
 /* Cleans up all allocated structures. */
 static void
 cleanup(sectionhead *sections)
 {
-    if (cur_objfmt && cur_objfmt->cleanup)
-       cur_objfmt->cleanup();
-    if (cur_dbgfmt && cur_dbgfmt->cleanup)
-       cur_dbgfmt->cleanup();
-    if (cur_preproc)
-       cur_preproc->cleanup();
-    if (sections)
-       sections_delete(sections);
-    symrec_cleanup();
-    if (cur_arch)
-       cur_arch->cleanup();
-
-    floatnum_cleanup();
-    intnum_cleanup();
-
-    yasm_errwarn.cleanup();
-    yasm_linemgr.cleanup();
-
-    BitVector_Shutdown();
+    if (DO_FREE) {
+       if (cur_objfmt && cur_objfmt->cleanup)
+           cur_objfmt->cleanup();
+       if (cur_dbgfmt && cur_dbgfmt->cleanup)
+           cur_dbgfmt->cleanup();
+       if (cur_preproc)
+           cur_preproc->cleanup();
+       if (sections)
+           sections_delete(sections);
+       symrec_cleanup();
+       if (cur_arch)
+           cur_arch->cleanup();
+
+       floatnum_cleanup();
+       intnum_cleanup();
+
+       yasm_errwarn.cleanup();
+       yasm_linemgr.cleanup();
+
+       BitVector_Shutdown();
+    }
 
     unload_modules();
 
     /* Finish with libltdl. */
     lt_dlexit();
 
-    if (in_filename)
-       xfree(in_filename);
-    if (obj_filename)
-       xfree(obj_filename);
+    if (DO_FREE) {
+       if (in_filename)
+           xfree(in_filename);
+       if (obj_filename)
+           xfree(obj_filename);
+    }
 }
 
 /*
index b4484ef96cd564c645dc47a6e201488a05bf66bf..ac8422d12645b542f1ad6ffc4e5c2b6d66ae8ba1 100644 (file)
@@ -469,39 +469,49 @@ open_obj(const char *mode)
     return obj;
 }
 
+/* Define DO_FREE to 1 to enable deallocation of all data structures.
+ * Useful for detecting memory leaks, but slows down execution unnecessarily
+ * (as the OS will free everything we miss here).
+ */
+#define DO_FREE                1
+
 /* Cleans up all allocated structures. */
 static void
 cleanup(sectionhead *sections)
 {
-    if (cur_objfmt && cur_objfmt->cleanup)
-       cur_objfmt->cleanup();
-    if (cur_dbgfmt && cur_dbgfmt->cleanup)
-       cur_dbgfmt->cleanup();
-    if (cur_preproc)
-       cur_preproc->cleanup();
-    if (sections)
-       sections_delete(sections);
-    symrec_cleanup();
-    if (cur_arch)
-       cur_arch->cleanup();
-
-    floatnum_cleanup();
-    intnum_cleanup();
-
-    yasm_errwarn.cleanup();
-    yasm_linemgr.cleanup();
-
-    BitVector_Shutdown();
+    if (DO_FREE) {
+       if (cur_objfmt && cur_objfmt->cleanup)
+           cur_objfmt->cleanup();
+       if (cur_dbgfmt && cur_dbgfmt->cleanup)
+           cur_dbgfmt->cleanup();
+       if (cur_preproc)
+           cur_preproc->cleanup();
+       if (sections)
+           sections_delete(sections);
+       symrec_cleanup();
+       if (cur_arch)
+           cur_arch->cleanup();
+
+       floatnum_cleanup();
+       intnum_cleanup();
+
+       yasm_errwarn.cleanup();
+       yasm_linemgr.cleanup();
+
+       BitVector_Shutdown();
+    }
 
     unload_modules();
 
     /* Finish with libltdl. */
     lt_dlexit();
 
-    if (in_filename)
-       xfree(in_filename);
-    if (obj_filename)
-       xfree(obj_filename);
+    if (DO_FREE) {
+       if (in_filename)
+           xfree(in_filename);
+       if (obj_filename)
+           xfree(obj_filename);
+    }
 }
 
 /*