summaryrefslogtreecommitdiff
path: root/dbg_mlc.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 /dbg_mlc.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 'dbg_mlc.c')
-rw-r--r--dbg_mlc.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/dbg_mlc.c b/dbg_mlc.c
index 724d9cff..4edeeefd 100644
--- a/dbg_mlc.c
+++ b/dbg_mlc.c
@@ -760,7 +760,8 @@ GC_API GC_ATTR_MALLOC char * GC_CALL GC_debug_strndup(const char *str,
# endif
return NULL;
}
- BCOPY(str, copy, len);
+ if (len > 0)
+ BCOPY(str, copy, len);
copy[len] = '\0';
return copy;
}
@@ -973,7 +974,8 @@ GC_API void * GC_CALL GC_debug_realloc(void * p, size_t lb, GC_EXTRA_PARAMS)
# else
old_sz = ((oh *)base) -> oh_sz;
# endif
- BCOPY(p, result, old_sz < lb ? old_sz : lb);
+ if (old_sz > 0)
+ BCOPY(p, result, old_sz < lb ? old_sz : lb);
GC_debug_free(p);
}
return(result);