summaryrefslogtreecommitdiff
path: root/av.c
diff options
context:
space:
mode:
authorIlya Zakharevich <ilya@math.berkeley.edu>1998-06-22 00:19:45 -0400
committerGurusamy Sarathy <gsar@cpan.org>1998-06-23 06:06:23 +0000
commit8d6dde3e637be6ce74eec8ca77c5be73d19f769a (patch)
treeeb37e8ea49be3485b48a74821f527ac1fde1a018 /av.c
parent276493cb78ba879defeed992c4543a6fe30f98ce (diff)
downloadperl-8d6dde3e637be6ce74eec8ca77c5be73d19f769a.tar.gz
applied patch, regen headers
Message-Id: <199806220819.EAA03295@monk.mps.ohio-state.edu> Subject: [PATCH 5.004_67] Malloc size feedback p4raw-id: //depot/perl@1201
Diffstat (limited to 'av.c')
-rw-r--r--av.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/av.c b/av.c
index 3ced5bef3b..36bfa9cc7e 100644
--- a/av.c
+++ b/av.c
@@ -92,9 +92,15 @@ av_extend(AV *av, I32 key)
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*);
@@ -114,6 +120,7 @@ av_extend(AV *av, I32 key)
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()?) */
@@ -123,7 +130,7 @@ av_extend(AV *av, I32 key)
}
}
else {
- newmax = key < 4 ? 4 : key;
+ newmax = key < 3 ? 3 : key;
New(2,AvALLOC(av), newmax+1, SV*);
ary = AvALLOC(av) + 1;
tmp = newmax;