#define magic_wipepack pPerl->Perl_magic_wipepack
#undef magicname
#define magicname pPerl->Perl_magicname
+#undef malloced_size
+#define malloced_size pPerl->Perl_malloced_size
#undef markstack_grow
#define markstack_grow pPerl->Perl_markstack_grow
#undef mem_collxfrm
U32 bytes;
#endif
+#ifdef MYMALLOC
+ newmax = malloced_size((void*)AvALLOC(av))/sizeof(SV*) - 1;
+
+ if (key <= newmax)
+ goto resized;
+#endif
newmax = key + AvMAX(av) / 5;
resize:
-#ifdef STRANGE_MALLOC
+#if defined(STRANGE_MALLOC) || defined(MYMALLOC)
Renew(AvALLOC(av),newmax+1, SV*);
#else
bytes = (newmax + 1) * sizeof(SV*);
Safefree(AvALLOC(av));
AvALLOC(av) = ary;
#endif
+ resized:
ary = AvALLOC(av) + AvMAX(av) + 1;
tmp = newmax - AvMAX(av);
if (av == curstack) { /* Oops, grew stack (via av_store()?) */
}
}
else {
- newmax = key < 4 ? 4 : key;
+ newmax = key < 3 ? 3 : key;
New(2,AvALLOC(av), newmax+1, SV*);
ary = AvALLOC(av) + 1;
tmp = newmax;
#define magic_sizepack Perl_magic_sizepack
#define magic_wipepack Perl_magic_wipepack
#define magicname Perl_magicname
+#define malloced_size Perl_malloced_size
#define markstack_grow Perl_markstack_grow
#define mem_collxfrm Perl_mem_collxfrm
#define mess Perl_mess
magic_sizepack
magic_wipepack
magicname
+malloced_size
markstack_grow
mem_collxfrm
mess
I32 oldsize = (I32) xhv->xhv_max + 1; /* sic(k) */
register I32 newsize = oldsize * 2;
register I32 i;
- register HE **a;
+ register HE **a = (HE**)xhv->xhv_array;
register HE **b;
register HE *entry;
register HE **oentry;
I32 tmp;
#endif
- a = (HE**)xhv->xhv_array;
nomemok = TRUE;
-#ifdef STRANGE_MALLOC
+#if defined(STRANGE_MALLOC) || defined(MYMALLOC)
Renew(a, newsize, HE*);
if (!a) {
nomemok = FALSE;
a = (HE**)xhv->xhv_array;
if (a) {
nomemok = TRUE;
-#ifdef STRANGE_MALLOC
+#if defined(STRANGE_MALLOC) || defined(MYMALLOC)
Renew(a, newsize, HE*);
if (!a) {
nomemok = FALSE;
MEM_SIZE
malloced_size(void *p)
{
- int bucket = OV_INDEX((union overhead *)p);
-
+ union overhead *ovp = (union overhead *)
+ ((caddr_t)p - sizeof (union overhead) * CHUNK_SHIFT);
+ int bucket = OV_INDEX(ovp);
+#ifdef RCHECK
+ /* The caller wants to have a complete control over the chunk,
+ disable the memory checking inside the chunk. */
+ if (bucket <= MAX_SHORT_BUCKET) {
+ MEM_SIZE size = BUCKET_SIZE_REAL(bucket);
+ ovp->ov_size = size + M_OVERHEAD - 1;
+ *((u_int *)((caddr_t)ovp + size + M_OVERHEAD - RSLOP)) = RMAGIC;
+ }
+#endif
return BUCKET_SIZE_REAL(bucket);
}
#define magic_wipepack CPerlObj::Perl_magic_wipepack
#undef magicname
#define magicname CPerlObj::Perl_magicname
+#undef malloced_size
+#define malloced_size CPerlObj::Perl_malloced_size
#undef markstack_grow
#define markstack_grow CPerlObj::Perl_markstack_grow
#undef markstack_ptr
thr = init_main_thread();
#endif /* USE_THREADS */
- linestr = NEWSV(65,80);
+ linestr = NEWSV(65,79);
sv_upgrade(linestr,SVt_PVIV);
if (!SvREADONLY(&sv_undef)) {
SV *sv;
for (;;) {
- sv = NEWSV(56, 80);
+ sv = NEWSV(56, 79);
if (sv_gets(sv, fp, 0) == Nullch) {
SvREFCNT_dec(sv);
break;
VIRTUAL int magic_wipepack _((SV* sv, MAGIC* mg));
VIRTUAL void magicname _((char* sym, char* name, I32 namlen));
int main _((int argc, char** argv, char** env));
+VIRTUAL MEM_SIZE malloced_size _((void *p));
VIRTUAL void markstack_grow _((void));
#ifdef USE_LOCALE_COLLATE
VIRTUAL char* mem_collxfrm _((const char* s, STRLEN len, STRLEN* xlen));
else
s = SvPVX(sv);
if (newlen > SvLEN(sv)) { /* need more room? */
- if (SvLEN(sv) && s)
+ if (SvLEN(sv) && s) {
+#ifdef MYMALLOC
+ STRLEN l = malloced_size((void*)SvPVX(sv));
+ if (newlen <= l) {
+ SvLEN_set(sv, l);
+ return s;
+ } else
+#endif
Renew(s,newlen,char);
+ }
else
New(703,s,newlen,char);
SvPV_set(sv, s);
s--, herewas = newSVpv(s,d-s);
s += SvCUR(herewas);
- tmpstr = NEWSV(87,80);
+ tmpstr = NEWSV(87,79);
sv_upgrade(tmpstr, SVt_PVIV);
if (term == '\'') {
op_type = OP_CONST;
multi_close = term;
/* create a new SV to hold the contents. 87 is leak category, I'm
- assuming. 80 is the SV's initial length. What a random number. */
- sv = NEWSV(87,80);
+ assuming. 79 is the SV's initial length. What a random number. */
+ sv = NEWSV(87,79);
sv_upgrade(sv, SVt_PVIV);
SvIVX(sv) = term;
(void)SvPOK_only(sv); /* validate pointer */