aboutsummaryrefslogtreecommitdiffstats
path: root/src/gmalloc.c
diff options
context:
space:
mode:
authorWolfgang Jenkner2016-02-09 15:04:40 -0800
committerPaul Eggert2016-02-09 15:25:58 -0800
commit09ece4d341a7e07fab7be22868ebcadae8641c79 (patch)
tree5bd96d0c6b88c1a017212ef912200c5b7e5b8ba9 /src/gmalloc.c
parenta0e3180db181d1bc7ccb883f8f2b55e76a3703f2 (diff)
downloademacs-09ece4d341a7e07fab7be22868ebcadae8641c79.tar.gz
emacs-09ece4d341a7e07fab7be22868ebcadae8641c79.zip
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);
72#undef free 72#undef free
73#define malloc gmalloc 73#define malloc gmalloc
74#define realloc grealloc 74#define realloc grealloc
75#define calloc do_not_call_me /* Emacs never calls calloc. */ 75#define calloc gcalloc
76#define aligned_alloc galigned_alloc 76#define aligned_alloc galigned_alloc
77#define free gfree 77#define free gfree
78#define malloc_info gmalloc_info 78#define malloc_info gmalloc_info
@@ -101,6 +101,8 @@ extern void *malloc (size_t size) ATTRIBUTE_MALLOC_SIZE ((1));
101/* Re-allocate the previously allocated block 101/* Re-allocate the previously allocated block
102 in ptr, making the new block SIZE bytes long. */ 102 in ptr, making the new block SIZE bytes long. */
103extern void *realloc (void *ptr, size_t size) ATTRIBUTE_ALLOC_SIZE ((2)); 103extern void *realloc (void *ptr, size_t size) ATTRIBUTE_ALLOC_SIZE ((2));
104/* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */
105extern void *calloc (size_t nmemb, size_t size) ATTRIBUTE_MALLOC_SIZE ((1,2));
104/* Free a block. */ 106/* Free a block. */
105extern void free (void *ptr); 107extern void free (void *ptr);
106 108
@@ -1465,7 +1467,6 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
1465 1467
1466/* Allocate an array of NMEMB elements each SIZE bytes long. 1468/* Allocate an array of NMEMB elements each SIZE bytes long.
1467 The entire array is initialized to zeros. */ 1469 The entire array is initialized to zeros. */
1468#ifndef calloc
1469void * 1470void *
1470calloc (size_t nmemb, size_t size) 1471calloc (size_t nmemb, size_t size)
1471{ 1472{
@@ -1483,7 +1484,6 @@ calloc (size_t nmemb, size_t size)
1483 return memset (result, 0, bytes); 1484 return memset (result, 0, bytes);
1484 return result; 1485 return result;
1485} 1486}
1486#endif
1487/* Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. 1487/* Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
1488This file is part of the GNU C Library. 1488This file is part of the GNU C Library.
1489 1489
@@ -1714,6 +1714,7 @@ valloc (size_t size)
1714/* Declare system malloc and friends. */ 1714/* Declare system malloc and friends. */
1715extern void *malloc (size_t size); 1715extern void *malloc (size_t size);
1716extern void *realloc (void *ptr, size_t size); 1716extern void *realloc (void *ptr, size_t size);
1717extern void *calloc (size_t nmemb, size_t size);
1717extern void free (void *ptr); 1718extern void free (void *ptr);
1718#ifdef HAVE_ALIGNED_ALLOC 1719#ifdef HAVE_ALIGNED_ALLOC
1719extern void *aligned_alloc (size_t alignment, size_t size); 1720extern void *aligned_alloc (size_t alignment, size_t size);
@@ -1732,6 +1733,14 @@ hybrid_malloc (size_t size)
1732 return gmalloc (size); 1733 return gmalloc (size);
1733} 1734}
1734 1735
1736void *
1737hybrid_calloc (size_t nmemb, size_t size)
1738{
1739 if (DUMPED)
1740 return calloc (nmemb, size);
1741 return gcalloc (nmemb, size);
1742}
1743
1735void 1744void
1736hybrid_free (void *ptr) 1745hybrid_free (void *ptr)
1737{ 1746{