summaryrefslogtreecommitdiff
path: root/solenv
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2014-05-22 14:21:09 +0200
committerStephan Bergmann <sbergman@redhat.com>2014-05-22 14:21:09 +0200
commit92cb4099c46f62f537db93a59c3141bce1355924 (patch)
treee4638dffbe7efcc18722bc7dfddfdbe3be0f23a2 /solenv
parent5db9861383f054c6e2018c0e90d31ee1c89b25b4 (diff)
concat-deps: Clean up memory at exit when run with lsan
Change-Id: I66ccb5332e6c5eceb2f199911ebd4296c93cac4b
Diffstat (limited to 'solenv')
-rw-r--r--solenv/bin/concat-deps.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/solenv/bin/concat-deps.c b/solenv/bin/concat-deps.c
index 439deb9848d0..4a2230988a91 100644
--- a/solenv/bin/concat-deps.c
+++ b/solenv/bin/concat-deps.c
@@ -74,6 +74,8 @@
#include <unistd.h>
#endif
+#include <config_options.h>
+
/* modes */
#ifdef __windows
#define FILE_O_RDONLY _O_RDONLY
@@ -590,6 +592,11 @@ off_t size = -1;
return size;
}
+#if !ENABLE_RUNTIME_OPTIMIZATIONS
+static void * file_load_buffers[100];
+static size_t file_load_buffer_count = 0;
+#endif
+
static char* file_load(const char* name, off_t* size, int* return_rc)
{
off_t local_size = 0;
@@ -610,6 +617,20 @@ int fd;
if (!(fd == -1))
{
buffer = malloc((size_t)(*size + 1));
+#if !ENABLE_RUNTIME_OPTIMIZATIONS
+ if (buffer != NULL)
+ {
+ if (file_load_buffer_count == 100)
+ {
+ free(buffer);
+ buffer = NULL;
+ }
+ else
+ {
+ file_load_buffers[file_load_buffer_count++] = buffer;
+ }
+ }
+#endif
if (buffer == NULL)
{
rc = ENOMEM;
@@ -1089,7 +1110,7 @@ off_t in_list_size = 0;
char* in_list;
char* in_list_cursor;
char* in_list_base;
-struct hash* dep_hash;
+struct hash* dep_hash = 0;
const char *env_str;
if(argc < 2)
@@ -1149,6 +1170,13 @@ const char *env_str;
dep_hash->collisions, dep_hash->memcmp, dep_hash->cost);
#endif
}
+#if !ENABLE_RUNTIME_OPTIMIZATIONS
+ hash_destroy(dep_hash);
+ for (size_t i = 0; i != file_load_buffer_count; ++i)
+ {
+ free(file_load_buffers[i]);
+ }
+#endif
return rc;
}