git.droids-corp.org
/
protos
/
libecoli.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
3b0444e
)
alloc stats
author
Olivier Matz
<zer0@droids-corp.org>
Thu, 3 Aug 2017 20:29:21 +0000
(22:29 +0200)
committer
Olivier Matz
<zer0@droids-corp.org>
Thu, 3 Aug 2017 20:29:21 +0000
(22:29 +0200)
lib/main.c
patch
|
blob
|
history
diff --git
a/lib/main.c
b/lib/main.c
index
25cc4ca
..
51b0946
100644
(file)
--- a/
lib/main.c
+++ b/
lib/main.c
@@
-42,6
+42,7
@@
static int log_level = EC_LOG_INFO;
static int alloc_fail_proba = 0;
static int seed = 0;
static int log_level = EC_LOG_INFO;
static int alloc_fail_proba = 0;
static int seed = 0;
+static size_t alloc_success = 0;
static const char ec_short_options[] =
"h" /* help */
static const char ec_short_options[] =
"h" /* help */
@@
-201,6
+202,8
@@
static void *debug_malloc(size_t size, const char *file, unsigned int line)
ec_log(EC_LOG_DEBUG, "%s:%d: info: malloc(%zd) -> %p\n",
file, line, size, ret);
ec_log(EC_LOG_DEBUG, "%s:%d: info: malloc(%zd) -> %p\n",
file, line, size, ret);
+ if (ret)
+ alloc_success++;
return ret;
}
return ret;
}
@@
-313,6
+316,8
@@
static void *debug_realloc(void *ptr, size_t size, const char *file,
ec_log(EC_LOG_DEBUG, "%s:%d: info: realloc(%p, %zd) -> %p\n",
file, line, ptr, size, ret);
ec_log(EC_LOG_DEBUG, "%s:%d: info: realloc(%p, %zd) -> %p\n",
file, line, ptr, size, ret);
+ if (ret)
+ alloc_success++;
return ret;
}
return ret;
}
@@
-322,6
+327,8
@@
static int debug_alloc_dump_leaks(void)
int i;
char **buffer;
int i;
char **buffer;
+ ec_log(EC_LOG_INFO, "%zd successful allocations\n", alloc_success);
+
if (TAILQ_EMPTY(&debug_alloc_hdr_list))
return 0;
if (TAILQ_EMPTY(&debug_alloc_hdr_list))
return 0;