-/* Memory allocator `malloc'.
- Copyright 1990, 1991, 1992 Free Software Foundation
+/* Memory allocator `malloc'. */
- Written May 1989 by Mike Haertel.
- Heavily modified Mar 1992 by Fred Fish for mmap'd version. */
-
-/* Copyright (c) 2010-2013. The SimGrid Team.
+/* Copyright (c) 2010-2014. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
+/* Copyright 1990, 1991, 1992 Free Software Foundation
+
+ Written May 1989 by Mike Haertel.
+ Heavily modified Mar 1992 by Fred Fish for mmap'd version. */
+
#include <string.h> /* Prototypes for memcpy, memmove, memset, etc */
#include <stdio.h>
#include "mmprivate.h"
/* 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);
/* Allocate memory from the heap. */
void *mmalloc(xbt_mheap_t mdp, size_t size) {
void *res= mmalloc_no_memset(mdp,size);
-// fprintf(stderr,"malloc(%zu)~>%p\n",size,res);
- memset(res,0,size);
+ if (mdp->options & XBT_MHEAP_OPTION_MEMSET) {
+ memset(res,0,size);
+ }
return res;
}
/* Spliting mmalloc this way is mandated by a trick in mrealloc, that gives