int luaI_lock (Object *object) { Word i; Word oldSize; if (tag(object) == LUA_T_NIL) return -1; for (i=0; i<lockSize; i++) if (tag(&lockArray[i]) == LUA_T_NIL) { lockArray[i] = *object; return i; } /* no more empty spaces */ oldSize = lockSize; if (lockArray == NULL) { lockSize = 10; lockArray = newvector(lockSize, Object); } else { lockSize = 3*oldSize/2 + 5; lockArray = growvector(lockArray, lockSize, Object); } for (i=oldSize; i<lockSize; i++) tag(&lockArray[i]) = LUA_T_NIL; lockArray[oldSize] = *object; return oldSize; }
static void code_byte (Byte c) { if (pc>maxcurr-2) /* 1 byte free to code HALT of main code */ { if (maxcurr >= MAX_INT) lua_error("code size overflow"); maxcurr *= 2; if (maxcurr >= MAX_INT) maxcurr = MAX_INT; basepc = growvector(basepc, maxcurr, Byte); } basepc[pc++] = c; }
/* ** Given a name, search it at symbol table and return its index. If not ** found, allocate it. */ Word luaI_findsymbol (TaggedString *t) { if (t->varindex == NOT_USED) { if (lua_ntable == lua_maxsymbol) lua_maxsymbol = growvector(&lua_table, lua_maxsymbol, Symbol, symbolEM, MAX_WORD); t->varindex = lua_ntable; lua_table[lua_ntable].varname = t; s_tag(lua_ntable) = LUA_T_NIL; lua_ntable++; } return t->varindex; }
static void growstack (void) { if (stack == &initial_stack) lua_initstack(); else { static int limit = STACK_LIMIT; StkId t = top-stack; Long stacksize = stackLimit - stack; stacksize = growvector(&stack, stacksize, Object, stackEM, limit+100); stackLimit = stack+stacksize; top = stack + t; if (stacksize >= limit) { limit = stacksize; lua_error(stackEM); } } }