diff options
| author | Wolfgang Jenkner | 2016-02-09 15:04:40 -0800 |
|---|---|---|
| committer | Paul Eggert | 2016-02-09 15:25:58 -0800 |
| commit | 09ece4d341a7e07fab7be22868ebcadae8641c79 (patch) | |
| tree | 5bd96d0c6b88c1a017212ef912200c5b7e5b8ba9 /src/gmalloc.c | |
| parent | a0e3180db181d1bc7ccb883f8f2b55e76a3703f2 (diff) | |
| download | emacs-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.c | 15 |
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. */ |
| 103 | extern void *realloc (void *ptr, size_t size) ATTRIBUTE_ALLOC_SIZE ((2)); | 103 | extern void *realloc (void *ptr, size_t size) ATTRIBUTE_ALLOC_SIZE ((2)); |
| 104 | /* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */ | ||
| 105 | extern void *calloc (size_t nmemb, size_t size) ATTRIBUTE_MALLOC_SIZE ((1,2)); | ||
| 104 | /* Free a block. */ | 106 | /* Free a block. */ |
| 105 | extern void free (void *ptr); | 107 | extern 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 | ||
| 1469 | void * | 1470 | void * |
| 1470 | calloc (size_t nmemb, size_t size) | 1471 | calloc (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. |
| 1488 | This file is part of the GNU C Library. | 1488 | This 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. */ |
| 1715 | extern void *malloc (size_t size); | 1715 | extern void *malloc (size_t size); |
| 1716 | extern void *realloc (void *ptr, size_t size); | 1716 | extern void *realloc (void *ptr, size_t size); |
| 1717 | extern void *calloc (size_t nmemb, size_t size); | ||
| 1717 | extern void free (void *ptr); | 1718 | extern void free (void *ptr); |
| 1718 | #ifdef HAVE_ALIGNED_ALLOC | 1719 | #ifdef HAVE_ALIGNED_ALLOC |
| 1719 | extern void *aligned_alloc (size_t alignment, size_t size); | 1720 | extern 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 | ||
| 1736 | void * | ||
| 1737 | hybrid_calloc (size_t nmemb, size_t size) | ||
| 1738 | { | ||
| 1739 | if (DUMPED) | ||
| 1740 | return calloc (nmemb, size); | ||
| 1741 | return gcalloc (nmemb, size); | ||
| 1742 | } | ||
| 1743 | |||
| 1735 | void | 1744 | void |
| 1736 | hybrid_free (void *ptr) | 1745 | hybrid_free (void *ptr) |
| 1737 | { | 1746 | { |