summaryrefslogtreecommitdiff
path: root/src/gmalloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gmalloc.c')
-rw-r--r--src/gmalloc.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/gmalloc.c b/src/gmalloc.c
index c19885d9f80..b6a96d55727 100644
--- a/src/gmalloc.c
+++ b/src/gmalloc.c
@@ -76,7 +76,6 @@ extern void *(*__morecore) (ptrdiff_t);
#ifdef HYBRID_MALLOC
# include "sheap.h"
-# define DUMPED bss_sbrk_did_unexec
#endif
#ifdef __cplusplus
@@ -1508,7 +1507,7 @@ static void *
gdefault_morecore (ptrdiff_t increment)
{
#ifdef HYBRID_MALLOC
- if (!DUMPED)
+ if (!definitely_will_not_unexec_p ())
{
return bss_sbrk (increment);
}
@@ -1726,6 +1725,8 @@ extern int posix_memalign (void **memptr, size_t alignment, size_t size);
static bool
allocated_via_gmalloc (void *ptr)
{
+ if (!__malloc_initialized)
+ return false;
size_t block = BLOCK (ptr);
size_t blockmax = _heaplimit - 1;
return block <= blockmax && _heapinfo[block].busy.type != 0;
@@ -1737,7 +1738,7 @@ allocated_via_gmalloc (void *ptr)
void *
hybrid_malloc (size_t size)
{
- if (DUMPED)
+ if (definitely_will_not_unexec_p ())
return malloc (size);
return gmalloc (size);
}
@@ -1745,7 +1746,7 @@ hybrid_malloc (size_t size)
void *
hybrid_calloc (size_t nmemb, size_t size)
{
- if (DUMPED)
+ if (definitely_will_not_unexec_p ())
return calloc (nmemb, size);
return gcalloc (nmemb, size);
}
@@ -1763,7 +1764,7 @@ hybrid_free (void *ptr)
void *
hybrid_aligned_alloc (size_t alignment, size_t size)
{
- if (!DUMPED)
+ if (!definitely_will_not_unexec_p ())
return galigned_alloc (alignment, size);
/* The following is copied from alloc.c */
#ifdef HAVE_ALIGNED_ALLOC
@@ -1786,7 +1787,7 @@ hybrid_realloc (void *ptr, size_t size)
return hybrid_malloc (size);
if (!allocated_via_gmalloc (ptr))
return realloc (ptr, size);
- if (!DUMPED)
+ if (!definitely_will_not_unexec_p ())
return grealloc (ptr, size);
/* The dumped emacs is trying to realloc storage allocated before