From 8c49e198654567f770a7d5081b886a7c35201d81 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 26 Dec 2000 16:46:09 -0200 Subject: explicit control of size for growing vectors --- ltm.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'ltm.c') diff --git a/ltm.c b/ltm.c index ffe7a38b..852dfd13 100644 --- a/ltm.c +++ b/ltm.c @@ -1,5 +1,5 @@ /* -** $Id: ltm.c,v 1.56 2000/10/31 13:10:24 roberto Exp roberto $ +** $Id: ltm.c,v 1.57 2000/11/30 18:50:47 roberto Exp roberto $ ** Tag methods ** See Copyright Notice in lua.h */ @@ -75,26 +75,26 @@ static void init_entry (lua_State *L, int tag) { void luaT_init (lua_State *L) { int t; - luaM_growvector(L, L->TMtable, 0, NUM_TAGS, struct TM, "", MAX_INT); + L->sizeTM = NUM_TAGS+2; + L->TMtable = luaM_newvector(L, L->sizeTM, struct TM); L->nblocks += NUM_TAGS*sizeof(struct TM); - L->last_tag = NUM_TAGS-1; - for (t=0; t<=L->last_tag; t++) + L->ntag = NUM_TAGS; + for (t=0; tntag; t++) init_entry(L, t); } LUA_API int lua_newtag (lua_State *L) { - luaM_growvector(L, L->TMtable, L->last_tag, 1, struct TM, - "tag table overflow", MAX_INT); + luaM_growvector(L, L->TMtable, L->ntag, L->sizeTM, struct TM, + MAX_INT, "tag table overflow"); L->nblocks += sizeof(struct TM); - L->last_tag++; - init_entry(L, L->last_tag); - return L->last_tag; + init_entry(L, L->ntag); + return L->ntag++; } static void checktag (lua_State *L, int tag) { - if (!(0 <= tag && tag <= L->last_tag)) + if (!(0 <= tag && tag < L->ntag)) luaO_verror(L, "%d is not a valid tag", tag); } -- cgit v1.2.3-55-g6feb