aboutsummaryrefslogtreecommitdiff
path: root/ldo.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-02-26 12:48:55 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-02-26 12:48:55 -0300
commit72d675aba78d59e22ebfadbe447f4f51ddab5a5c (patch)
tree2f43006cba58bcfc97f01ecdd6f00e35e92aa673 /ldo.c
parentba57f7d946bc0b600996f7a982b2fb644df76a98 (diff)
downloadlua-72d675aba78d59e22ebfadbe447f4f51ddab5a5c.tar.gz
lua-72d675aba78d59e22ebfadbe447f4f51ddab5a5c.tar.bz2
lua-72d675aba78d59e22ebfadbe447f4f51ddab5a5c.zip
macros "growvector" and "reallocvector" more compact
Diffstat (limited to 'ldo.c')
-rw-r--r--ldo.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/ldo.c b/ldo.c
index 2f20dd33..9f3b7af1 100644
--- a/ldo.c
+++ b/ldo.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.c,v 1.34 1999/02/22 14:17:24 roberto Exp roberto $ 2** $Id: ldo.c,v 1.35 1999/02/22 19:23:36 roberto Exp roberto $
3** Stack and Call structure of Lua 3** Stack and Call structure of Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -43,13 +43,12 @@ void luaD_init (void) {
43} 43}
44 44
45 45
46void luaD_checkstack (int n) 46void luaD_checkstack (int n) {
47{
48 struct Stack *S = &L->stack; 47 struct Stack *S = &L->stack;
49 if (S->last-S->top <= n) { 48 if (S->last-S->top <= n) {
50 StkId top = S->top-S->stack; 49 StkId top = S->top-S->stack;
51 int stacksize = (S->last-S->stack)+1+STACK_UNIT+n; 50 int stacksize = (S->last-S->stack)+STACK_UNIT+n;
52 S->stack = luaM_reallocvector(S->stack, stacksize, TObject); 51 luaM_reallocvector(S->stack, stacksize, TObject);
53 S->last = S->stack+(stacksize-1); 52 S->last = S->stack+(stacksize-1);
54 S->top = S->stack + top; 53 S->top = S->stack + top;
55 if (stacksize >= STACK_LIMIT) { /* stack overflow? */ 54 if (stacksize >= STACK_LIMIT) { /* stack overflow? */
@@ -65,8 +64,7 @@ void luaD_checkstack (int n)
65/* 64/*
66** Adjust stack. Set top to the given value, pushing NILs if needed. 65** Adjust stack. Set top to the given value, pushing NILs if needed.
67*/ 66*/
68void luaD_adjusttop (StkId newtop) 67void luaD_adjusttop (StkId newtop) {
69{
70 int diff = newtop-(L->stack.top-L->stack.stack); 68 int diff = newtop-(L->stack.top-L->stack.stack);
71 if (diff <= 0) 69 if (diff <= 0)
72 L->stack.top += diff; 70 L->stack.top += diff;