Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' into mc
[simgrid.git] / src / xbt / mmalloc / mmalloc.c
index 2fb4338..72ca5a0 100644 (file)
@@ -1,8 +1,4 @@
-/* Memory allocator `malloc'.
-   Copyright 1990, 1991, 1992 Free Software Foundation
-
-   Written May 1989 by Mike Haertel.
-   Heavily modified Mar 1992 by Fred Fish for mmap'd version. */
+/* Memory allocator `malloc'. */
 
 /* Copyright (c) 2010-2014. The SimGrid Team.
  * All rights reserved.                                                     */
@@ -10,6 +6,11 @@
 /* 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"
@@ -136,8 +137,9 @@ static void *register_morecore(struct mdesc *mdp, size_t size)
 /* 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