# define PERL_MAYBE_ALIVE 1
#endif
+#ifndef MYMALLOC
+# error "MYMALLOC is not defined"
+#endif
+
#ifndef MUTEX_LOCK
# define MUTEX_LOCK(l)
#endif
# define POW2_OPTIMIZE_SURPLUS(bucket) 0
#endif /* !TWO_POT_OPTIMIZE */
-#ifdef HAS_64K_LIMIT
-# define BARK_64K_LIMIT(what,nbytes,size) \
- if (nbytes > 0xffff) { \
- PerlIO_printf(PerlIO_stderr(), \
- "%s too large: %lx\n", what, size); \
- my_exit(1); \
- }
-#else /* !HAS_64K_LIMIT */
-# define BARK_64K_LIMIT(what,nbytes,size)
-#endif /* !HAS_64K_LIMIT */
+#define BARK_64K_LIMIT(what,nbytes,size)
#ifndef MIN_SBRK
# define MIN_SBRK 2048
# define SBRK_FAILURE_PRICE 50
#endif
-static void morecore (register int bucket);
+static void morecore (int bucket);
# if defined(DEBUGGING)
static void botch (const char *diag, const char *s, const char *file, int line);
# endif
return pv;
}
-/* Returns 0 on success, -1 on bad alignment, -2 if not implemented */
-int
-set_emergency_buffer(char *b, IV size)
-{
- if (PTR2UV(b) & (NEEDED_ALIGNMENT - 1))
- return -1;
- if (MallocCfg[MallocCfg_emergency_buffer_prepared_size])
- add_to_chain((void*)emergency_buffer_prepared,
- MallocCfg[MallocCfg_emergency_buffer_prepared_size], 0);
- emergency_buffer_prepared = b;
- MallocCfg[MallocCfg_emergency_buffer_prepared_size] = size;
- return 0;
-}
# define GET_EMERGENCY_BUFFER(p) get_emergency_buffer(p)
# else /* NO_MALLOC_DYNAMIC_CFG */
# define GET_EMERGENCY_BUFFER(p) NULL
-int
-set_emergency_buffer(char *b, IV size)
-{
- return -1;
-}
# endif
static Malloc_t
do_croak:
MALLOC_UNLOCK;
emergency_sbrk_croak("Out of memory during request for %"UVuf" bytes, total sbrk() is %"UVuf" bytes", (UV)size, (UV)(goodsbrk + sbrk_slack));
- assert(0); /* NOTREACHED */
+ NOT_REACHED; /* NOTREACHED */
return NULL;
}
#endif /* defined PERL_EMERGENCY_SBRK */
/* Don't use PerlIO buffered writes as they allocate memory. */
-#define MYMALLOC_WRITE2STDERR(s) PerlLIO_write(PerlIO_fileno(PerlIO_stderr()),s,strlen(s))
+#define MYMALLOC_WRITE2STDERR(s) PERL_UNUSED_RESULT(PerlLIO_write(PerlIO_fileno(PerlIO_stderr()),s,strlen(s)))
#ifdef DEBUGGING
#undef ASSERT
# define FILLCHECK_DEADBEEF(s, n) ((void)0)
#endif
-int
-S_ajust_size_and_find_bucket(size_t *nbytes_p)
+STATIC int
+S_adjust_size_and_find_bucket(size_t *nbytes_p)
{
- MEM_SIZE shiftr;
+ MEM_SIZE shiftr;
int bucket;
- size_t nbytes = *nbytes_p;
+ size_t nbytes;
+
+ PERL_ARGS_ASSERT_ADJUST_SIZE_AND_FIND_BUCKET;
+
+ nbytes = *nbytes_p;
/*
* Convert amount of memory requested into
croak("%s", "panic: malloc");
#endif
- bucket = S_ajust_size_and_find_bucket(&nbytes);
+ bucket = adjust_size_and_find_bucket(&nbytes);
MALLOC_LOCK;
/*
* If nothing in hash bucket right now,
if (add) {
DEBUG_m(PerlIO_printf(Perl_debug_log,
- "sbrk(%ld) to fix non-continuous/off-page sbrk:\n\t%ld for alignement,\t%ld were assumed to come from the tail of the previous sbrk\n",
+ "sbrk(%ld) to fix non-continuous/off-page sbrk:\n\t%ld for alignment,\t%ld were assumed to come from the tail of the previous sbrk\n",
(long)add, (long) slack,
(long) sbrked_remains));
newcp = (char *)sbrk(add);
* Allocate more memory to the indicated bucket.
*/
static void
-morecore(register int bucket)
+morecore(int bucket)
{
dVAR;
union overhead *ovp;
if (bad_free_warn == -1) {
dTHX;
char *pbf = PerlEnv_getenv("PERL_BADFREE");
- bad_free_warn = (pbf) ? atoi(pbf) : 1;
+ bad_free_warn = (pbf) ? strNE("0", pbf) : 1;
}
if (!bad_free_warn)
return;
if (bad_free_warn == -1) {
dTHX;
char *pbf = PerlEnv_getenv("PERL_BADFREE");
- bad_free_warn = (pbf) ? atoi(pbf) : 1;
+ bad_free_warn = (pbf) ? strNE("0", pbf) : 1;
}
if (!bad_free_warn)
return NULL;
}
Malloc_t
-Perl_calloc(register size_t elements, register size_t size)
+Perl_calloc(size_t elements, size_t size)
{
long sz = elements * size;
Malloc_t p = Perl_malloc(sz);
MEM_SIZE
Perl_malloc_good_size(size_t wanted)
{
- return BUCKET_SIZE_REAL(S_ajust_size_and_find_bucket(&wanted));
+ return BUCKET_SIZE_REAL(adjust_size_and_find_bucket(&wanted));
}
# ifdef BUCKETS_ROOT2
#ifdef USE_PERL_SBRK
-# if defined(NeXT) || defined(__NeXT__) || defined(PURIFY)
+# if defined(PURIFY)
# define PERL_SBRK_VIA_MALLOC
# endif
#endif /* ! defined USE_PERL_SBRK */
/*
- * Local variables:
- * c-indentation-style: bsd
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- *
* ex: set ts=8 sts=4 sw=4 et:
*/