summaryrefslogtreecommitdiff
path: root/scope.c
diff options
context:
space:
mode:
authorAlbert Dvornik <bert@genscan.com>1998-09-17 15:23:07 -0400
committerGurusamy Sarathy <gsar@cpan.org>1998-09-23 10:41:39 +0000
commit455ece5e082708b1bd94cff001612bd4efb4d2e9 (patch)
treee6679b1c862a8bfef5d2dcca86151ec7f7d39148 /scope.c
parent9ad0a0f606dfe6bb2ec67942ae23eef93c8ce770 (diff)
downloadperl-455ece5e082708b1bd94cff001612bd4efb4d2e9.tar.gz
SSNEW() API for allocating memory on the savestack
Message-Id: <tqemtae338.fsf@puma.genscan.com> Subject: [PATCH 5.005_51] (was: why SAVEDESTRUCTOR()...) p4raw-id: //depot/perl@1852
Diffstat (limited to 'scope.c')
-rw-r--r--scope.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/scope.c b/scope.c
index 067e29edaa..5ba56d2142 100644
--- a/scope.c
+++ b/scope.c
@@ -532,6 +532,24 @@ save_op(void)
SSPUSHINT(SAVEt_OP);
}
+I32
+save_alloc(I32 size, I32 pad)
+{
+ dTHR;
+ register I32 start = pad + ((char*)&PL_savestack[PL_savestack_ix]
+ - (char*)PL_savestack);
+ register I32 elems = 1 + ((size + pad - 1) / sizeof(*PL_savestack));
+
+ /* SSCHECK may not be good enough */
+ while (PL_savestack_ix + elems + 2 > PL_savestack_max)
+ savestack_grow();
+
+ PL_savestack_ix += elems;
+ SSPUSHINT(elems);
+ SSPUSHINT(SAVEt_ALLOC);
+ return start;
+}
+
void
leave_scope(I32 base)
{
@@ -759,6 +777,7 @@ leave_scope(I32 base)
(CALLDESTRUCTOR)(ptr);
break;
case SAVEt_REGCONTEXT:
+ case SAVEt_ALLOC:
i = SSPOPINT;
PL_savestack_ix -= i; /* regexp must have croaked */
break;