aboutsummaryrefslogtreecommitdiff
path: root/lapi.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-12-26 16:46:09 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-12-26 16:46:09 -0200
commit8c49e198654567f770a7d5081b886a7c35201d81 (patch)
tree8c1de3e885ef138574e51a8868f175feeaab71e2 /lapi.c
parent6af005ec20323defd2a5ead01e2d389462884d04 (diff)
downloadlua-8c49e198654567f770a7d5081b886a7c35201d81.tar.gz
lua-8c49e198654567f770a7d5081b886a7c35201d81.tar.bz2
lua-8c49e198654567f770a7d5081b886a7c35201d81.zip
explicit control of size for growing vectors
Diffstat (limited to 'lapi.c')
-rw-r--r--lapi.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/lapi.c b/lapi.c
index bb7516e9..b1b7d0ff 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 1.111 2000/11/24 17:39:56 roberto Exp roberto $ 2** $Id: lapi.c,v 1.112 2000/12/04 18:33:40 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*/
@@ -289,7 +289,7 @@ LUA_API void lua_getglobals (lua_State *L) {
289LUA_API int lua_getref (lua_State *L, int ref) { 289LUA_API int lua_getref (lua_State *L, int ref) {
290 if (ref == LUA_REFNIL) 290 if (ref == LUA_REFNIL)
291 ttype(L->top) = LUA_TNIL; 291 ttype(L->top) = LUA_TNIL;
292 else if (0 <= ref && ref < L->refSize && 292 else if (0 <= ref && ref < L->nref &&
293 (L->refArray[ref].st == LOCK || L->refArray[ref].st == HOLD)) 293 (L->refArray[ref].st == LOCK || L->refArray[ref].st == HOLD))
294 *L->top = L->refArray[ref].o; 294 *L->top = L->refArray[ref].o;
295 else 295 else
@@ -360,10 +360,10 @@ LUA_API int lua_ref (lua_State *L, int lock) {
360 L->refFree = L->refArray[ref].st; 360 L->refFree = L->refArray[ref].st;
361 } 361 }
362 else { /* no more free places */ 362 else { /* no more free places */
363 luaM_growvector(L, L->refArray, L->refSize, 1, struct Ref, 363 luaM_growvector(L, L->refArray, L->nref, L->sizeref, struct Ref,
364 "reference table overflow", MAX_INT); 364 MAX_INT, "reference table overflow");
365 L->nblocks += sizeof(struct Ref); 365 L->nblocks += sizeof(struct Ref);
366 ref = L->refSize++; 366 ref = L->nref++;
367 } 367 }
368 L->refArray[ref].o = *(L->top-1); 368 L->refArray[ref].o = *(L->top-1);
369 L->refArray[ref].st = lock ? LOCK : HOLD; 369 L->refArray[ref].st = lock ? LOCK : HOLD;
@@ -430,7 +430,7 @@ LUA_API void lua_settag (lua_State *L, int tag) {
430 430
431LUA_API void lua_unref (lua_State *L, int ref) { 431LUA_API void lua_unref (lua_State *L, int ref) {
432 if (ref >= 0) { 432 if (ref >= 0) {
433 LUA_ASSERT(ref < L->refSize && L->refArray[ref].st < 0, "invalid ref"); 433 LUA_ASSERT(ref < L->nref && L->refArray[ref].st < 0, "invalid ref");
434 L->refArray[ref].st = L->refFree; 434 L->refArray[ref].st = L->refFree;
435 L->refFree = ref; 435 L->refFree = ref;
436 } 436 }