diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-05-11 11:19:32 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-05-11 11:19:32 -0300 |
commit | 6eb1399a1c662f45ab5511a5e7d35fdb967ec076 (patch) | |
tree | cec3750f9655d6abb1829cb0f2f72c5497d584f8 /lapi.c | |
parent | c390f73e3b3853fb64a057bdcc2a79fc87e13ad3 (diff) | |
download | lua-6eb1399a1c662f45ab5511a5e7d35fdb967ec076.tar.gz lua-6eb1399a1c662f45ab5511a5e7d35fdb967ec076.tar.bz2 lua-6eb1399a1c662f45ab5511a5e7d35fdb967ec076.zip |
array Cblocks should grow dynamically
Diffstat (limited to 'lapi.c')
-rw-r--r-- | lapi.c | 26 |
1 files changed, 15 insertions, 11 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 1.41 1999/03/04 21:17:26 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.42 1999/03/26 13:14:00 roberto Exp roberto $ |
3 | ** Lua API | 3 | ** Lua API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -637,16 +637,22 @@ char *lua_getobjname (lua_Object o, char **name) | |||
637 | */ | 637 | */ |
638 | 638 | ||
639 | 639 | ||
640 | void lua_beginblock (void) | 640 | #ifndef MAX_C_BLOCKS |
641 | { | 641 | #define MAX_C_BLOCKS 500 |
642 | if (L->numCblocks >= MAX_C_BLOCKS) | 642 | #endif |
643 | lua_error("too many nested blocks"); | 643 | |
644 | |||
645 | void lua_beginblock (void) { | ||
646 | if (L->numCblocks >= L->sizeCblocks) { | ||
647 | luaM_growvector(L->Cblocks, L->numCblocks, 1, struct C_Lua_Stack, | ||
648 | "too many nested blocks", MAX_C_BLOCKS); | ||
649 | L->sizeCblocks++; | ||
650 | } | ||
644 | L->Cblocks[L->numCblocks] = L->Cstack; | 651 | L->Cblocks[L->numCblocks] = L->Cstack; |
645 | L->numCblocks++; | 652 | L->numCblocks++; |
646 | } | 653 | } |
647 | 654 | ||
648 | void lua_endblock (void) | 655 | void lua_endblock (void) { |
649 | { | ||
650 | --L->numCblocks; | 656 | --L->numCblocks; |
651 | L->Cstack = L->Cblocks[L->numCblocks]; | 657 | L->Cstack = L->Cblocks[L->numCblocks]; |
652 | luaD_adjusttop(L->Cstack.base); | 658 | luaD_adjusttop(L->Cstack.base); |
@@ -654,8 +660,7 @@ void lua_endblock (void) | |||
654 | 660 | ||
655 | 661 | ||
656 | 662 | ||
657 | int lua_ref (int lock) | 663 | int lua_ref (int lock) { |
658 | { | ||
659 | int ref; | 664 | int ref; |
660 | checkCparams(1); | 665 | checkCparams(1); |
661 | ref = luaC_ref(L->stack.top-1, lock); | 666 | ref = luaC_ref(L->stack.top-1, lock); |
@@ -665,8 +670,7 @@ int lua_ref (int lock) | |||
665 | 670 | ||
666 | 671 | ||
667 | 672 | ||
668 | lua_Object lua_getref (int ref) | 673 | lua_Object lua_getref (int ref) { |
669 | { | ||
670 | TObject *o = luaC_getref(ref); | 674 | TObject *o = luaC_getref(ref); |
671 | return (o ? put_luaObject(o) : LUA_NOOBJECT); | 675 | return (o ? put_luaObject(o) : LUA_NOOBJECT); |
672 | } | 676 | } |