summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2008-02-27 19:11:12 +0000
committerNicholas Clark <nick@ccl4.org>2008-02-27 19:11:12 +0000
commitd8fca4022b56f335fb492e336b5d155376eb1bf7 (patch)
tree5782cd9ec92f2203934b6f0f38f71916e4e1e90d /sv.c
parent641071807211a3969bcad26ac3f2a39f4550a11c (diff)
downloadperl-d8fca4022b56f335fb492e336b5d155376eb1bf7.tar.gz
Use malloc_good_size() to round up the size of requested arenas to the
size that will actually be allocated, to squeeze last few bytes into use. p4raw-id: //depot/perl@33390
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/sv.c b/sv.c
index 49dc3f5a99..1db4b92759 100644
--- a/sv.c
+++ b/sv.c
@@ -1045,6 +1045,7 @@ S_more_bodies (pTHX_ const svtype sv_type)
const size_t body_size = bdp->body_size;
char *start;
const char *end;
+ const size_t arena_size = Perl_malloc_good_size(bdp->arena_size);
#if defined(DEBUGGING) && !defined(PERL_GLOBAL_STRUCT_PRIVATE)
static bool done_sanity_check;
@@ -1062,20 +1063,28 @@ S_more_bodies (pTHX_ const svtype sv_type)
assert(bdp->arena_size);
- start = (char*) Perl_get_arena(aTHX_ bdp->arena_size, sv_type);
+ start = (char*) Perl_get_arena(aTHX_ arena_size, sv_type);
- end = start + bdp->arena_size - body_size;
+ end = start + arena_size - 2 * body_size;
/* computed count doesnt reflect the 1st slot reservation */
+#if defined(MYMALLOC) || defined(HAS_MALLOC_GOOD_SIZE)
+ DEBUG_m(PerlIO_printf(Perl_debug_log,
+ "arena %p end %p arena-size %d (from %d) type %d "
+ "size %d ct %d\n",
+ (void*)start, (void*)end, (int)arena_size,
+ (int)bdp->arena_size, sv_type, (int)body_size,
+ (int)arena_size / (int)body_size));
+#else
DEBUG_m(PerlIO_printf(Perl_debug_log,
"arena %p end %p arena-size %d type %d size %d ct %d\n",
(void*)start, (void*)end,
(int)bdp->arena_size, sv_type, (int)body_size,
(int)bdp->arena_size / (int)body_size));
-
+#endif
*root = (void *)start;
- while (start < end) {
+ while (start <= end) {
char * const next = start + body_size;
*(void**) start = (void *)next;
start = next;