Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Let's still pass the tests with mmalloc and MC in the library
[simgrid.git] / src / xbt / mmalloc / mcalloc.c
1 /* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
2    This file was then part of the GNU C Library. */
3
4 /* Copyright (c) 2010. The SimGrid Team.
5  * All rights reserved.                                                     */
6
7 /* This program is free software; you can redistribute it and/or modify it
8  * under the terms of the license (GNU LGPL) which comes with this package. */
9
10 #include <sys/types.h>  /* GCC on HP/UX needs this before string.h. */
11 #include <string.h>     /* Prototypes for memcpy, memmove, memset, etc */
12
13 #include "mmprivate.h"
14
15 /* Allocate an array of NMEMB elements each SIZE bytes long.
16    The entire array is initialized to zeros.  */
17
18 void *
19 mcalloc (void *md, register size_t nmemb, register size_t size)
20 {
21   register void* result;
22
23   if ((result = mmalloc (md, nmemb * size)) != NULL)
24     {
25       memset (result, 0, nmemb * size);
26     }
27   return (result);
28 }
29
30 /* When using this package, provide a version of malloc/realloc/free built
31    on top of it, so that if we use the default sbrk() region we will not
32    collide with another malloc package trying to do the same thing, if
33    the application contains any "hidden" calls to malloc/realloc/free (such
34    as inside a system library).
35    FIXME: disabled for now */
36
37 //void* calloc (size_t nmemb, size_t size) {
38 //  return (mcalloc ((void*) NULL, nmemb, size));
39 //}