diff options
Diffstat (limited to 'src/gmalloc.c')
| -rw-r--r-- | src/gmalloc.c | 156 |
1 files changed, 67 insertions, 89 deletions
diff --git a/src/gmalloc.c b/src/gmalloc.c index 4fd324686ba..4feff83a2d1 100644 --- a/src/gmalloc.c +++ b/src/gmalloc.c | |||
| @@ -25,6 +25,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. | |||
| 25 | #define USE_PTHREAD | 25 | #define USE_PTHREAD |
| 26 | #endif | 26 | #endif |
| 27 | 27 | ||
| 28 | #include <stddef.h> | ||
| 28 | #include <string.h> | 29 | #include <string.h> |
| 29 | #include <limits.h> | 30 | #include <limits.h> |
| 30 | #include <stdint.h> | 31 | #include <stdint.h> |
| @@ -38,6 +39,26 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. | |||
| 38 | #include <w32heap.h> /* for sbrk */ | 39 | #include <w32heap.h> /* for sbrk */ |
| 39 | #endif | 40 | #endif |
| 40 | 41 | ||
| 42 | #ifdef emacs | ||
| 43 | # include "lisp.h" | ||
| 44 | #endif | ||
| 45 | |||
| 46 | #ifdef HAVE_MALLOC_H | ||
| 47 | # if 4 < __GNUC__ + (2 <= __GNUC_MINOR__) | ||
| 48 | # pragma GCC diagnostic ignored "-Wdeprecated-declarations" | ||
| 49 | # endif | ||
| 50 | # include <malloc.h> | ||
| 51 | #endif | ||
| 52 | #ifndef __MALLOC_HOOK_VOLATILE | ||
| 53 | # define __MALLOC_HOOK_VOLATILE volatile | ||
| 54 | #endif | ||
| 55 | #ifndef HAVE_MALLOC_H | ||
| 56 | extern void (*__MALLOC_HOOK_VOLATILE __after_morecore_hook) (void); | ||
| 57 | extern void (*__MALLOC_HOOK_VOLATILE __malloc_initialize_hook) (void); | ||
| 58 | extern void *(*__morecore) (ptrdiff_t); | ||
| 59 | extern void *__default_morecore (ptrdiff_t); | ||
| 60 | #endif | ||
| 61 | |||
| 41 | /* If HYBRID_MALLOC is defined, then temacs will use malloc, | 62 | /* If HYBRID_MALLOC is defined, then temacs will use malloc, |
| 42 | realloc... as defined in this file (and renamed gmalloc, | 63 | realloc... as defined in this file (and renamed gmalloc, |
| 43 | grealloc... via the macros that follow). The dumped emacs, | 64 | grealloc... via the macros that follow). The dumped emacs, |
| @@ -58,9 +79,10 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. | |||
| 58 | #undef free | 79 | #undef free |
| 59 | #define malloc gmalloc | 80 | #define malloc gmalloc |
| 60 | #define realloc grealloc | 81 | #define realloc grealloc |
| 61 | #define calloc gcalloc | 82 | #define calloc do_not_call_me /* Emacs never calls calloc. */ |
| 62 | #define aligned_alloc galigned_alloc | 83 | #define aligned_alloc galigned_alloc |
| 63 | #define free gfree | 84 | #define free gfree |
| 85 | #define malloc_info gmalloc_info | ||
| 64 | 86 | ||
| 65 | #ifdef HYBRID_MALLOC | 87 | #ifdef HYBRID_MALLOC |
| 66 | # include "sheap.h" | 88 | # include "sheap.h" |
| @@ -77,15 +99,6 @@ extern "C" | |||
| 77 | { | 99 | { |
| 78 | #endif | 100 | #endif |
| 79 | 101 | ||
| 80 | #include <stddef.h> | ||
| 81 | |||
| 82 | /* Underlying allocation function; successive calls should | ||
| 83 | return contiguous pieces of memory. */ | ||
| 84 | extern void *(*__morecore) (ptrdiff_t size); | ||
| 85 | |||
| 86 | /* Default value of `__morecore'. */ | ||
| 87 | extern void *__default_morecore (ptrdiff_t size); | ||
| 88 | |||
| 89 | #ifdef HYBRID_MALLOC | 102 | #ifdef HYBRID_MALLOC |
| 90 | #define extern static | 103 | #define extern static |
| 91 | #endif | 104 | #endif |
| @@ -95,9 +108,7 @@ extern void *malloc (size_t size) ATTRIBUTE_MALLOC_SIZE ((1)); | |||
| 95 | /* Re-allocate the previously allocated block | 108 | /* Re-allocate the previously allocated block |
| 96 | in ptr, making the new block SIZE bytes long. */ | 109 | in ptr, making the new block SIZE bytes long. */ |
| 97 | extern void *realloc (void *ptr, size_t size) ATTRIBUTE_ALLOC_SIZE ((2)); | 110 | extern void *realloc (void *ptr, size_t size) ATTRIBUTE_ALLOC_SIZE ((2)); |
| 98 | /* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */ | 111 | /* Free a block. */ |
| 99 | extern void *calloc (size_t nmemb, size_t size) ATTRIBUTE_MALLOC_SIZE ((1,2)); | ||
| 100 | /* Free a block allocated by `malloc', `realloc' or `calloc'. */ | ||
| 101 | extern void free (void *ptr); | 112 | extern void free (void *ptr); |
| 102 | 113 | ||
| 103 | /* Allocate SIZE bytes allocated to ALIGNMENT bytes. */ | 114 | /* Allocate SIZE bytes allocated to ALIGNMENT bytes. */ |
| @@ -107,11 +118,6 @@ extern void *memalign (size_t, size_t); | |||
| 107 | extern int posix_memalign (void **, size_t, size_t); | 118 | extern int posix_memalign (void **, size_t, size_t); |
| 108 | #endif | 119 | #endif |
| 109 | 120 | ||
| 110 | #ifdef USE_PTHREAD | ||
| 111 | /* Set up mutexes and make malloc etc. thread-safe. */ | ||
| 112 | extern void malloc_enable_thread (void); | ||
| 113 | #endif | ||
| 114 | |||
| 115 | /* The allocator divides the heap into blocks of fixed size; large | 121 | /* The allocator divides the heap into blocks of fixed size; large |
| 116 | requests receive one or more whole blocks, and small requests | 122 | requests receive one or more whole blocks, and small requests |
| 117 | receive a fragment of a block. Fragment sizes are powers of two, | 123 | receive a fragment of a block. Fragment sizes are powers of two, |
| @@ -243,26 +249,11 @@ extern int _malloc_thread_enabled_p; | |||
| 243 | #define UNLOCK_ALIGNED_BLOCKS() | 249 | #define UNLOCK_ALIGNED_BLOCKS() |
| 244 | #endif | 250 | #endif |
| 245 | 251 | ||
| 246 | /* If not NULL, this function is called after each time | ||
| 247 | `__morecore' is called to increase the data size. */ | ||
| 248 | extern void (*__after_morecore_hook) (void); | ||
| 249 | |||
| 250 | /* Number of extra blocks to get each time we ask for more core. | ||
| 251 | This reduces the frequency of calling `(*__morecore)'. */ | ||
| 252 | extern size_t __malloc_extra_blocks; | ||
| 253 | |||
| 254 | /* Nonzero if `malloc' has been called and done its initialization. */ | 252 | /* Nonzero if `malloc' has been called and done its initialization. */ |
| 255 | extern int __malloc_initialized; | 253 | extern int __malloc_initialized; |
| 256 | /* Function called to initialize malloc data structures. */ | 254 | /* Function called to initialize malloc data structures. */ |
| 257 | extern int __malloc_initialize (void); | 255 | extern int __malloc_initialize (void); |
| 258 | 256 | ||
| 259 | /* Hooks for debugging versions. */ | ||
| 260 | extern void (*__malloc_initialize_hook) (void); | ||
| 261 | extern void (*__free_hook) (void *ptr); | ||
| 262 | extern void *(*__malloc_hook) (size_t size); | ||
| 263 | extern void *(*__realloc_hook) (void *ptr, size_t size); | ||
| 264 | extern void *(*__memalign_hook) (size_t size, size_t alignment); | ||
| 265 | |||
| 266 | #ifdef GC_MCHECK | 257 | #ifdef GC_MCHECK |
| 267 | 258 | ||
| 268 | /* Return values for `mprobe': these are the kinds of inconsistencies that | 259 | /* Return values for `mprobe': these are the kinds of inconsistencies that |
| @@ -304,9 +295,6 @@ struct mstats | |||
| 304 | /* Pick up the current statistics. */ | 295 | /* Pick up the current statistics. */ |
| 305 | extern struct mstats mstats (void); | 296 | extern struct mstats mstats (void); |
| 306 | 297 | ||
| 307 | /* Call WARNFUN with a warning message when memory usage is high. */ | ||
| 308 | extern void memory_warnings (void *start, void (*warnfun) (const char *)); | ||
| 309 | |||
| 310 | #endif | 298 | #endif |
| 311 | 299 | ||
| 312 | #undef extern | 300 | #undef extern |
| @@ -337,13 +325,11 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. | |||
| 337 | 325 | ||
| 338 | #include <errno.h> | 326 | #include <errno.h> |
| 339 | 327 | ||
| 340 | void *(*__morecore) (ptrdiff_t size) = __default_morecore; | 328 | /* Debugging hook for 'malloc'. */ |
| 329 | static void *(*__MALLOC_HOOK_VOLATILE gmalloc_hook) (size_t); | ||
| 341 | 330 | ||
| 342 | #ifndef HYBRID_MALLOC | 331 | #ifndef HYBRID_MALLOC |
| 343 | 332 | ||
| 344 | /* Debugging hook for `malloc'. */ | ||
| 345 | void *(*__malloc_hook) (size_t size); | ||
| 346 | |||
| 347 | /* Pointer to the base of the first block. */ | 333 | /* Pointer to the base of the first block. */ |
| 348 | char *_heapbase; | 334 | char *_heapbase; |
| 349 | 335 | ||
| @@ -368,10 +354,9 @@ size_t _bytes_free; | |||
| 368 | /* Are you experienced? */ | 354 | /* Are you experienced? */ |
| 369 | int __malloc_initialized; | 355 | int __malloc_initialized; |
| 370 | 356 | ||
| 371 | size_t __malloc_extra_blocks; | 357 | void (*__MALLOC_HOOK_VOLATILE __malloc_initialize_hook) (void); |
| 372 | 358 | void (*__MALLOC_HOOK_VOLATILE __after_morecore_hook) (void); | |
| 373 | void (*__malloc_initialize_hook) (void); | 359 | void *(*__morecore) (ptrdiff_t); |
| 374 | void (*__after_morecore_hook) (void); | ||
| 375 | 360 | ||
| 376 | #else | 361 | #else |
| 377 | 362 | ||
| @@ -379,6 +364,13 @@ static struct list _fraghead[BLOCKLOG]; | |||
| 379 | 364 | ||
| 380 | #endif /* HYBRID_MALLOC */ | 365 | #endif /* HYBRID_MALLOC */ |
| 381 | 366 | ||
| 367 | /* Number of extra blocks to get each time we ask for more core. | ||
| 368 | This reduces the frequency of calling `(*__morecore)'. */ | ||
| 369 | #if defined DOUG_LEA_MALLOC || defined HYBRID_MALLOC || defined SYSTEM_MALLOC | ||
| 370 | static | ||
| 371 | #endif | ||
| 372 | size_t __malloc_extra_blocks; | ||
| 373 | |||
| 382 | /* Number of info entries. */ | 374 | /* Number of info entries. */ |
| 383 | static size_t heapsize; | 375 | static size_t heapsize; |
| 384 | 376 | ||
| @@ -935,15 +927,15 @@ malloc (size_t size) | |||
| 935 | if (!__malloc_initialized && !__malloc_initialize ()) | 927 | if (!__malloc_initialized && !__malloc_initialize ()) |
| 936 | return NULL; | 928 | return NULL; |
| 937 | 929 | ||
| 938 | /* Copy the value of __malloc_hook to an automatic variable in case | 930 | /* Copy the value of gmalloc_hook to an automatic variable in case |
| 939 | __malloc_hook is modified in another thread between its | 931 | gmalloc_hook is modified in another thread between its |
| 940 | NULL-check and the use. | 932 | NULL-check and the use. |
| 941 | 933 | ||
| 942 | Note: Strictly speaking, this is not a right solution. We should | 934 | Note: Strictly speaking, this is not a right solution. We should |
| 943 | use mutexes to access non-read-only variables that are shared | 935 | use mutexes to access non-read-only variables that are shared |
| 944 | among multiple threads. We just leave it for compatibility with | 936 | among multiple threads. We just leave it for compatibility with |
| 945 | glibc malloc (i.e., assignments to __malloc_hook) for now. */ | 937 | glibc malloc (i.e., assignments to gmalloc_hook) for now. */ |
| 946 | hook = __malloc_hook; | 938 | hook = gmalloc_hook; |
| 947 | return (hook != NULL ? *hook : _malloc_internal) (size); | 939 | return (hook != NULL ? *hook : _malloc_internal) (size); |
| 948 | } | 940 | } |
| 949 | 941 | ||
| @@ -995,10 +987,10 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. | |||
| 995 | The author may be reached (Email) at the address mike@ai.mit.edu, | 987 | The author may be reached (Email) at the address mike@ai.mit.edu, |
| 996 | or (US mail) as Mike Haertel c/o Free Software Foundation. */ | 988 | or (US mail) as Mike Haertel c/o Free Software Foundation. */ |
| 997 | 989 | ||
| 990 | /* Debugging hook for free. */ | ||
| 991 | static void (*__MALLOC_HOOK_VOLATILE gfree_hook) (void *); | ||
| 998 | 992 | ||
| 999 | #ifndef HYBRID_MALLOC | 993 | #ifndef HYBRID_MALLOC |
| 1000 | /* Debugging hook for free. */ | ||
| 1001 | void (*__free_hook) (void *__ptr); | ||
| 1002 | 994 | ||
| 1003 | /* List of blocks allocated by aligned_alloc. */ | 995 | /* List of blocks allocated by aligned_alloc. */ |
| 1004 | struct alignlist *_aligned_blocks = NULL; | 996 | struct alignlist *_aligned_blocks = NULL; |
| @@ -1251,7 +1243,7 @@ _free_internal_nolock (void *ptr) | |||
| 1251 | } | 1243 | } |
| 1252 | 1244 | ||
| 1253 | /* Return memory to the heap. | 1245 | /* Return memory to the heap. |
| 1254 | Like `free' but don't call a __free_hook if there is one. */ | 1246 | Like 'free' but don't call a hook if there is one. */ |
| 1255 | void | 1247 | void |
| 1256 | _free_internal (void *ptr) | 1248 | _free_internal (void *ptr) |
| 1257 | { | 1249 | { |
| @@ -1265,7 +1257,7 @@ _free_internal (void *ptr) | |||
| 1265 | void | 1257 | void |
| 1266 | free (void *ptr) | 1258 | free (void *ptr) |
| 1267 | { | 1259 | { |
| 1268 | void (*hook) (void *) = __free_hook; | 1260 | void (*hook) (void *) = gfree_hook; |
| 1269 | 1261 | ||
| 1270 | if (hook != NULL) | 1262 | if (hook != NULL) |
| 1271 | (*hook) (ptr); | 1263 | (*hook) (ptr); |
| @@ -1309,10 +1301,8 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. | |||
| 1309 | #define min(a, b) ((a) < (b) ? (a) : (b)) | 1301 | #define min(a, b) ((a) < (b) ? (a) : (b)) |
| 1310 | #endif | 1302 | #endif |
| 1311 | 1303 | ||
| 1312 | #ifndef HYBRID_MALLOC | ||
| 1313 | /* Debugging hook for realloc. */ | 1304 | /* Debugging hook for realloc. */ |
| 1314 | void *(*__realloc_hook) (void *ptr, size_t size); | 1305 | static void *(*grealloc_hook) (void *, size_t); |
| 1315 | #endif | ||
| 1316 | 1306 | ||
| 1317 | /* Resize the given region to the new size, returning a pointer | 1307 | /* Resize the given region to the new size, returning a pointer |
| 1318 | to the (possibly moved) region. This is optimized for speed; | 1308 | to the (possibly moved) region. This is optimized for speed; |
| @@ -1456,7 +1446,7 @@ realloc (void *ptr, size_t size) | |||
| 1456 | if (!__malloc_initialized && !__malloc_initialize ()) | 1446 | if (!__malloc_initialized && !__malloc_initialize ()) |
| 1457 | return NULL; | 1447 | return NULL; |
| 1458 | 1448 | ||
| 1459 | hook = __realloc_hook; | 1449 | hook = grealloc_hook; |
| 1460 | return (hook != NULL ? *hook : _realloc_internal) (ptr, size); | 1450 | return (hook != NULL ? *hook : _realloc_internal) (ptr, size); |
| 1461 | } | 1451 | } |
| 1462 | /* Copyright (C) 1991, 1992, 1994 Free Software Foundation, Inc. | 1452 | /* Copyright (C) 1991, 1992, 1994 Free Software Foundation, Inc. |
| @@ -1479,6 +1469,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. | |||
| 1479 | 1469 | ||
| 1480 | /* Allocate an array of NMEMB elements each SIZE bytes long. | 1470 | /* Allocate an array of NMEMB elements each SIZE bytes long. |
| 1481 | The entire array is initialized to zeros. */ | 1471 | The entire array is initialized to zeros. */ |
| 1472 | #ifndef calloc | ||
| 1482 | void * | 1473 | void * |
| 1483 | calloc (size_t nmemb, size_t size) | 1474 | calloc (size_t nmemb, size_t size) |
| 1484 | { | 1475 | { |
| @@ -1496,6 +1487,7 @@ calloc (size_t nmemb, size_t size) | |||
| 1496 | return memset (result, 0, bytes); | 1487 | return memset (result, 0, bytes); |
| 1497 | return result; | 1488 | return result; |
| 1498 | } | 1489 | } |
| 1490 | #endif | ||
| 1499 | /* Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. | 1491 | /* Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. |
| 1500 | This file is part of the GNU C Library. | 1492 | This file is part of the GNU C Library. |
| 1501 | 1493 | ||
| @@ -1541,6 +1533,9 @@ __default_morecore (ptrdiff_t increment) | |||
| 1541 | return NULL; | 1533 | return NULL; |
| 1542 | return result; | 1534 | return result; |
| 1543 | } | 1535 | } |
| 1536 | |||
| 1537 | void *(*__morecore) (ptrdiff_t) = __default_morecore; | ||
| 1538 | |||
| 1544 | /* Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc. | 1539 | /* Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc. |
| 1545 | 1540 | ||
| 1546 | This library is free software; you can redistribute it and/or | 1541 | This library is free software; you can redistribute it and/or |
| @@ -1556,19 +1551,11 @@ General Public License for more details. | |||
| 1556 | You should have received a copy of the GNU General Public | 1551 | You should have received a copy of the GNU General Public |
| 1557 | License along with this library. If not, see <http://www.gnu.org/licenses/>. */ | 1552 | License along with this library. If not, see <http://www.gnu.org/licenses/>. */ |
| 1558 | 1553 | ||
| 1559 | #ifndef HYBRID_MALLOC | ||
| 1560 | void *(*__memalign_hook) (size_t size, size_t alignment); | ||
| 1561 | #endif | ||
| 1562 | |||
| 1563 | void * | 1554 | void * |
| 1564 | aligned_alloc (size_t alignment, size_t size) | 1555 | aligned_alloc (size_t alignment, size_t size) |
| 1565 | { | 1556 | { |
| 1566 | void *result; | 1557 | void *result; |
| 1567 | size_t adj, lastadj; | 1558 | size_t adj, lastadj; |
| 1568 | void *(*hook) (size_t, size_t) = __memalign_hook; | ||
| 1569 | |||
| 1570 | if (hook) | ||
| 1571 | return (*hook) (alignment, size); | ||
| 1572 | 1559 | ||
| 1573 | /* Allocate a block with enough extra space to pad the block with up to | 1560 | /* Allocate a block with enough extra space to pad the block with up to |
| 1574 | (ALIGNMENT - 1) bytes if necessary. */ | 1561 | (ALIGNMENT - 1) bytes if necessary. */ |
| @@ -1731,7 +1718,6 @@ valloc (size_t size) | |||
| 1731 | /* Declare system malloc and friends. */ | 1718 | /* Declare system malloc and friends. */ |
| 1732 | extern void *malloc (size_t size); | 1719 | extern void *malloc (size_t size); |
| 1733 | extern void *realloc (void *ptr, size_t size); | 1720 | extern void *realloc (void *ptr, size_t size); |
| 1734 | extern void *calloc (size_t nmemb, size_t size); | ||
| 1735 | extern void free (void *ptr); | 1721 | extern void free (void *ptr); |
| 1736 | #ifdef HAVE_ALIGNED_ALLOC | 1722 | #ifdef HAVE_ALIGNED_ALLOC |
| 1737 | extern void *aligned_alloc (size_t alignment, size_t size); | 1723 | extern void *aligned_alloc (size_t alignment, size_t size); |
| @@ -1750,14 +1736,6 @@ hybrid_malloc (size_t size) | |||
| 1750 | return gmalloc (size); | 1736 | return gmalloc (size); |
| 1751 | } | 1737 | } |
| 1752 | 1738 | ||
| 1753 | void * | ||
| 1754 | hybrid_calloc (size_t nmemb, size_t size) | ||
| 1755 | { | ||
| 1756 | if (DUMPED) | ||
| 1757 | return calloc (nmemb, size); | ||
| 1758 | return gcalloc (nmemb, size); | ||
| 1759 | } | ||
| 1760 | |||
| 1761 | void | 1739 | void |
| 1762 | hybrid_free (void *ptr) | 1740 | hybrid_free (void *ptr) |
| 1763 | { | 1741 | { |
| @@ -1947,9 +1925,9 @@ freehook (void *ptr) | |||
| 1947 | else | 1925 | else |
| 1948 | hdr = NULL; | 1926 | hdr = NULL; |
| 1949 | 1927 | ||
| 1950 | __free_hook = old_free_hook; | 1928 | gfree_hook = old_free_hook; |
| 1951 | free (hdr); | 1929 | free (hdr); |
| 1952 | __free_hook = freehook; | 1930 | gfree_hook = freehook; |
| 1953 | } | 1931 | } |
| 1954 | 1932 | ||
| 1955 | static void * | 1933 | static void * |
| @@ -1957,9 +1935,9 @@ mallochook (size_t size) | |||
| 1957 | { | 1935 | { |
| 1958 | struct hdr *hdr; | 1936 | struct hdr *hdr; |
| 1959 | 1937 | ||
| 1960 | __malloc_hook = old_malloc_hook; | 1938 | gmalloc_hook = old_malloc_hook; |
| 1961 | hdr = malloc (sizeof *hdr + size + 1); | 1939 | hdr = malloc (sizeof *hdr + size + 1); |
| 1962 | __malloc_hook = mallochook; | 1940 | gmalloc_hook = mallochook; |
| 1963 | if (hdr == NULL) | 1941 | if (hdr == NULL) |
| 1964 | return NULL; | 1942 | return NULL; |
| 1965 | 1943 | ||
| @@ -1985,13 +1963,13 @@ reallochook (void *ptr, size_t size) | |||
| 1985 | memset ((char *) ptr + size, FREEFLOOD, osize - size); | 1963 | memset ((char *) ptr + size, FREEFLOOD, osize - size); |
| 1986 | } | 1964 | } |
| 1987 | 1965 | ||
| 1988 | __free_hook = old_free_hook; | 1966 | gfree_hook = old_free_hook; |
| 1989 | __malloc_hook = old_malloc_hook; | 1967 | gmalloc_hook = old_malloc_hook; |
| 1990 | __realloc_hook = old_realloc_hook; | 1968 | grealloc_hook = old_realloc_hook; |
| 1991 | hdr = realloc (hdr, sizeof *hdr + size + 1); | 1969 | hdr = realloc (hdr, sizeof *hdr + size + 1); |
| 1992 | __free_hook = freehook; | 1970 | gfree_hook = freehook; |
| 1993 | __malloc_hook = mallochook; | 1971 | gmalloc_hook = mallochook; |
| 1994 | __realloc_hook = reallochook; | 1972 | grealloc_hook = reallochook; |
| 1995 | if (hdr == NULL) | 1973 | if (hdr == NULL) |
| 1996 | return NULL; | 1974 | return NULL; |
| 1997 | 1975 | ||
| @@ -2048,12 +2026,12 @@ mcheck (void (*func) (enum mcheck_status)) | |||
| 2048 | /* These hooks may not be safely inserted if malloc is already in use. */ | 2026 | /* These hooks may not be safely inserted if malloc is already in use. */ |
| 2049 | if (!__malloc_initialized && !mcheck_used) | 2027 | if (!__malloc_initialized && !mcheck_used) |
| 2050 | { | 2028 | { |
| 2051 | old_free_hook = __free_hook; | 2029 | old_free_hook = gfree_hook; |
| 2052 | __free_hook = freehook; | 2030 | gfree_hook = freehook; |
| 2053 | old_malloc_hook = __malloc_hook; | 2031 | old_malloc_hook = gmalloc_hook; |
| 2054 | __malloc_hook = mallochook; | 2032 | gmalloc_hook = mallochook; |
| 2055 | old_realloc_hook = __realloc_hook; | 2033 | old_realloc_hook = grealloc_hook; |
| 2056 | __realloc_hook = reallochook; | 2034 | grealloc_hook = reallochook; |
| 2057 | mcheck_used = 1; | 2035 | mcheck_used = 1; |
| 2058 | } | 2036 | } |
| 2059 | 2037 | ||