summaryrefslogtreecommitdiff
path: root/reclaim.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2017-08-09 11:10:38 +0300
committerIvan Maidanski <ivmai@mail.ru>2017-08-09 11:26:14 +0300
commitc4f8f000273f029e9aebc8eb305a21975c853786 (patch)
treef808bf98b7fe334fabeaf01dfbfc054d80a84875 /reclaim.c
parent348bc2ba8d5556f4e655675b94e1b29e80b40fdc (diff)
downloadbdwgc-c4f8f000273f029e9aebc8eb305a21975c853786.tar.gz
Do not call BCOPY and BZERO if size is zero
* dbg_mlc.c (GC_debug_strndup): Do not call BCOPY() if elements count is zero. * dbg_mlc.c (GC_debug_realloc): Likewise. * finalize.c [!GC_TOGGLE_REFS_NOT_NEEDED] (ensure_toggleref_capacity): Likewise. * malloc.c [REDIRECT_MALLOC && !strndup] (strndup): Likewise. * mallocx.c (GC_strndup): Likewise. * misc.c [!GC_GET_HEAP_USAGE_NOT_NEEDED] (GC_get_prof_stats): Likewise. * os_dep.c [SAVE_CALL_CHAIN && GC_HAVE_BUILTIN_BACKTRACE] (GC_save_callers): Likewise. * reclaim.c (GC_print_all_errors): Likewise. * malloc.c (GC_free): Do not call BZERO() if elements count is zero. * malloc.c [THREADS] (GC_free_inner): Likewise. * reclaim.c (GC_print_all_errors): Likewise. * misc.c [!GC_GET_HEAP_USAGE_NOT_NEEDED && THREADS] (GC_get_prof_stats_unsafe): Do not call fill_prof_stats() and BCOPY() if stats_sz is zero.
Diffstat (limited to 'reclaim.c')
-rw-r--r--reclaim.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/reclaim.c b/reclaim.c
index 2361406e..2f491218 100644
--- a/reclaim.c
+++ b/reclaim.c
@@ -82,10 +82,12 @@ GC_INNER void GC_print_all_errors(void)
have_errors = GC_have_errors;
printing_errors = TRUE;
n_leaked = GC_n_leaked;
- GC_ASSERT(n_leaked <= MAX_LEAKED);
- BCOPY(GC_leaked, leaked, n_leaked * sizeof(ptr_t));
- GC_n_leaked = 0;
- BZERO(GC_leaked, n_leaked * sizeof(ptr_t));
+ if (n_leaked > 0) {
+ GC_ASSERT(n_leaked <= MAX_LEAKED);
+ BCOPY(GC_leaked, leaked, n_leaked * sizeof(ptr_t));
+ GC_n_leaked = 0;
+ BZERO(GC_leaked, n_leaked * sizeof(ptr_t));
+ }
UNLOCK();
if (GC_debugging_started) {