summaryrefslogtreecommitdiff
path: root/src/gmalloc.c
diff options
context:
space:
mode:
authorWolfgang Jenkner <wjenkner@inode.at>2016-02-09 15:04:40 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2016-02-09 15:25:58 -0800
commit09ece4d341a7e07fab7be22868ebcadae8641c79 (patch)
tree5bd96d0c6b88c1a017212ef912200c5b7e5b8ba9 /src/gmalloc.c
parenta0e3180db181d1bc7ccb883f8f2b55e76a3703f2 (diff)
downloademacs-09ece4d341a7e07fab7be22868ebcadae8641c79.tar.gz
Restore the calloc family.
* src/gmalloc.c (calloc, gcalloc, hybrid_calloc): Restore definitions. They were lost in a4817d8 but calloc is still (marginally) used in code statically liked with emacs, so hybrid_calloc is needed. Also, in the non-hybrid case, we can't get rid of calloc anyway as other libraries liked with emacs may need it. * src/conf_post.h: Restore redefinition of calloc to hybrid_calloc.
Diffstat (limited to 'src/gmalloc.c')
-rw-r--r--src/gmalloc.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/gmalloc.c b/src/gmalloc.c
index 0b76aeef04d..dd18293dc7e 100644
--- a/src/gmalloc.c
+++ b/src/gmalloc.c
@@ -72,7 +72,7 @@ extern void *(*__morecore) (ptrdiff_t);
#undef free
#define malloc gmalloc
#define realloc grealloc
-#define calloc do_not_call_me /* Emacs never calls calloc. */
+#define calloc gcalloc
#define aligned_alloc galigned_alloc
#define free gfree
#define malloc_info gmalloc_info
@@ -101,6 +101,8 @@ extern void *malloc (size_t size) ATTRIBUTE_MALLOC_SIZE ((1));
/* Re-allocate the previously allocated block
in ptr, making the new block SIZE bytes long. */
extern void *realloc (void *ptr, size_t size) ATTRIBUTE_ALLOC_SIZE ((2));
+/* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */
+extern void *calloc (size_t nmemb, size_t size) ATTRIBUTE_MALLOC_SIZE ((1,2));
/* Free a block. */
extern void free (void *ptr);
@@ -1465,7 +1467,6 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
/* Allocate an array of NMEMB elements each SIZE bytes long.
The entire array is initialized to zeros. */
-#ifndef calloc
void *
calloc (size_t nmemb, size_t size)
{
@@ -1483,7 +1484,6 @@ calloc (size_t nmemb, size_t size)
return memset (result, 0, bytes);
return result;
}
-#endif
/* Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -1714,6 +1714,7 @@ valloc (size_t size)
/* Declare system malloc and friends. */
extern void *malloc (size_t size);
extern void *realloc (void *ptr, size_t size);
+extern void *calloc (size_t nmemb, size_t size);
extern void free (void *ptr);
#ifdef HAVE_ALIGNED_ALLOC
extern void *aligned_alloc (size_t alignment, size_t size);
@@ -1732,6 +1733,14 @@ hybrid_malloc (size_t size)
return gmalloc (size);
}
+void *
+hybrid_calloc (size_t nmemb, size_t size)
+{
+ if (DUMPED)
+ return calloc (nmemb, size);
+ return gcalloc (nmemb, size);
+}
+
void
hybrid_free (void *ptr)
{