From e48f73aca9a0963b1e0879242211f2b51bb66fee Mon Sep 17 00:00:00 2001 From: Gabriel Corona Date: Fri, 11 Jul 2014 12:04:34 +0200 Subject: [PATCH] [mmalloc] Avoid useless memset0 --- src/xbt/mmalloc/mmalloc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/xbt/mmalloc/mmalloc.c b/src/xbt/mmalloc/mmalloc.c index 72ca5a0cd6..c91b4a06cb 100644 --- a/src/xbt/mmalloc/mmalloc.c +++ b/src/xbt/mmalloc/mmalloc.c @@ -97,9 +97,12 @@ static void *register_morecore(struct mdesc *mdp, size_t size) /* Copy old info into new location */ oldinfo = mdp->heapinfo; newinfo = (malloc_info *) align(mdp, newsize * sizeof(malloc_info)); - memset(newinfo, 0, newsize * sizeof(malloc_info)); memcpy(newinfo, oldinfo, mdp->heapsize * sizeof(malloc_info)); + /* Initialise the new blockinfo : */ + memset((char*) newinfo + mdp->heapsize * sizeof(malloc_info), 0, + (newsize - mdp->heapsize)* sizeof(malloc_info)); + /* Update the swag of busy blocks containing free fragments by applying the offset to all swag_hooks. Yeah. My hand is right in the fan and I still type */ size_t offset=((char*)newinfo)-((char*)oldinfo); -- 2.20.1