From 4a1bfd9a25fa2b60dd146d55d56c9e4635e76e06 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Fri, 3 Feb 2012 17:22:05 +0100 Subject: [PATCH] I don't need an extra file just to define calloc when it can be inlined that easily --- include/xbt/mmalloc.h | 3 --- src/xbt/mmalloc/mcalloc.c | 26 -------------------------- src/xbt/mmalloc/mm.c | 1 - src/xbt/mmalloc/mm_legacy.c | 4 +++- 4 files changed, 3 insertions(+), 31 deletions(-) delete mode 100644 src/xbt/mmalloc/mcalloc.c diff --git a/include/xbt/mmalloc.h b/include/xbt/mmalloc.h index 53d0c84453..a9d33eef1f 100644 --- a/include/xbt/mmalloc.h +++ b/include/xbt/mmalloc.h @@ -34,9 +34,6 @@ extern void *mmalloc(xbt_mheap_t md, size_t size); SIZE bytes long. */ extern void *mrealloc(xbt_mheap_t md, void *ptr, size_t size); -/* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */ -extern void *mcalloc(xbt_mheap_t md, size_t nmemb, size_t size); - /* Free a block allocated by `mmalloc', `mrealloc' or `mcalloc'. */ extern void mfree(xbt_mheap_t md, void *ptr); diff --git a/src/xbt/mmalloc/mcalloc.c b/src/xbt/mmalloc/mcalloc.c deleted file mode 100644 index 6c94d46a76..0000000000 --- a/src/xbt/mmalloc/mcalloc.c +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright (C) 1991, 1992 Free Software Foundation, Inc. - This file was then part of the GNU C Library. */ - -/* Copyright (c) 2010. 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. */ - -#include /* GCC on HP/UX needs this before string.h. */ -#include /* Prototypes for memcpy, memmove, memset, etc */ - -#include "mmprivate.h" - -/* Allocate an array of NMEMB elements each SIZE bytes long. - The entire array is initialized to zeros. */ - -void *mcalloc(xbt_mheap_t md, register size_t nmemb, register size_t size) -{ - register void *result; - - if ((result = mmalloc(md, nmemb * size)) != NULL) { - memset(result, 0, nmemb * size); - } - return (result); -} diff --git a/src/xbt/mmalloc/mm.c b/src/xbt/mmalloc/mm.c index b8ef55cb5a..c25f26d50e 100644 --- a/src/xbt/mmalloc/mm.c +++ b/src/xbt/mmalloc/mm.c @@ -15,7 +15,6 @@ #ifdef HAVE_UNISTD_H #include /* Prototypes for lseek, sbrk (maybe) */ #endif -#include "mcalloc.c" #include "mfree.c" #include "mmalloc.c" #include "mrealloc.c" diff --git a/src/xbt/mmalloc/mm_legacy.c b/src/xbt/mmalloc/mm_legacy.c index b353835634..02e04b6dee 100644 --- a/src/xbt/mmalloc/mm_legacy.c +++ b/src/xbt/mmalloc/mm_legacy.c @@ -49,8 +49,10 @@ void *calloc(size_t nmemb, size_t size) xbt_mheap_t mdp = __mmalloc_current_heap ?: (xbt_mheap_t) mmalloc_preinit(); LOCK(mdp); - void *ret = mcalloc(mdp, nmemb,size); + void *ret = mmalloc(mdp, nmemb*size); UNLOCK(mdp); + memset(ret, 0, nmemb * size); + return ret; } -- 2.20.1