Blame patch-2.7.6-improve_support_for_memory_leak_detection.patch
|
|
9dc0ea4 |
commit 2b584aec9e5f2806b1eccadcabe7e901fcfa0b0a
|
|
|
9dc0ea4 |
Author: Andreas Gruenbacher <agruen@gnu.org>
|
|
|
9dc0ea4 |
Date: Thu Jun 27 11:02:02 2019 +0200
|
|
|
9dc0ea4 |
|
|
|
9dc0ea4 |
Improve support for memory leak detection
|
|
|
9dc0ea4 |
|
|
|
9dc0ea4 |
When building with the address sanitizer on, free some more resources before
|
|
|
9dc0ea4 |
exiting. (This is unnecessary when not looking for memory leaks.)
|
|
|
9dc0ea4 |
* src/patch.c (init_files_to_delete): Add dispose function for freeing
|
|
|
9dc0ea4 |
filenames.
|
|
|
9dc0ea4 |
|
|
|
9dc0ea4 |
diff --git a/src/patch.c b/src/patch.c
|
|
|
9dc0ea4 |
index 81c7a02..4616a48 100644
|
|
|
9dc0ea4 |
--- a/src/patch.c
|
|
|
9dc0ea4 |
+++ b/src/patch.c
|
|
|
9dc0ea4 |
@@ -36,6 +36,10 @@
|
|
|
9dc0ea4 |
#include <minmax.h>
|
|
|
9dc0ea4 |
#include <safe.h>
|
|
|
9dc0ea4 |
|
|
|
9dc0ea4 |
+#ifdef __SANITIZE_ADDRESS__
|
|
|
9dc0ea4 |
+# define FREE_BEFORE_EXIT
|
|
|
9dc0ea4 |
+#endif
|
|
|
9dc0ea4 |
+
|
|
|
9dc0ea4 |
/* procedures */
|
|
|
9dc0ea4 |
|
|
|
9dc0ea4 |
static FILE *create_output_file (char const *, int);
|
|
|
9dc0ea4 |
@@ -1777,10 +1781,20 @@ struct file_to_delete {
|
|
|
9dc0ea4 |
|
|
|
9dc0ea4 |
static gl_list_t files_to_delete;
|
|
|
9dc0ea4 |
|
|
|
9dc0ea4 |
+#ifdef FREE_BEFORE_EXIT
|
|
|
9dc0ea4 |
+void dispose_file_to_delete (const void *elt)
|
|
|
9dc0ea4 |
+{
|
|
|
9dc0ea4 |
+ free ((void *) elt);
|
|
|
9dc0ea4 |
+}
|
|
|
9dc0ea4 |
+#else
|
|
|
9dc0ea4 |
+#define dispose_file_to_delete NULL
|
|
|
9dc0ea4 |
+#endif
|
|
|
9dc0ea4 |
+
|
|
|
9dc0ea4 |
static void
|
|
|
9dc0ea4 |
init_files_to_delete (void)
|
|
|
9dc0ea4 |
{
|
|
|
9dc0ea4 |
- files_to_delete = gl_list_create_empty (GL_LINKED_LIST, NULL, NULL, NULL, true);
|
|
|
9dc0ea4 |
+ files_to_delete = gl_list_create_empty (GL_LINKED_LIST, NULL, NULL,
|
|
|
9dc0ea4 |
+ dispose_file_to_delete, true);
|
|
|
9dc0ea4 |
}
|
|
|
9dc0ea4 |
|
|
|
9dc0ea4 |
static void
|