aboutsummaryrefslogtreecommitdiff
path: root/lstate.c
diff options
context:
space:
mode:
Diffstat (limited to 'lstate.c')
-rw-r--r--lstate.c30
1 files changed, 3 insertions, 27 deletions
diff --git a/lstate.c b/lstate.c
index b91daf5b..34c86bb1 100644
--- a/lstate.c
+++ b/lstate.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstate.c,v 1.27 2000/06/12 13:52:05 roberto Exp roberto $ 2** $Id: lstate.c,v 1.28 2000/06/30 14:35:17 roberto Exp roberto $
3** Global State 3** Global State
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -27,7 +27,7 @@
27lua_State *lua_state = NULL; 27lua_State *lua_state = NULL;
28 28
29 29
30static lua_State *newstate_aux (int stacksize, int put_builtin) { 30lua_State *lua_newstate (int stacksize, int put_builtin) {
31 lua_State *L = luaM_new(NULL, lua_State); 31 lua_State *L = luaM_new(NULL, lua_State);
32 L->errorJmp = NULL; 32 L->errorJmp = NULL;
33 L->Mbuffer = NULL; 33 L->Mbuffer = NULL;
@@ -50,6 +50,7 @@ static lua_State *newstate_aux (int stacksize, int put_builtin) {
50 L->linehook = NULL; 50 L->linehook = NULL;
51 L->allowhooks = 1; 51 L->allowhooks = 1;
52 L->gt = luaH_new(L, 10); 52 L->gt = luaH_new(L, 10);
53 if (stacksize == 0) stacksize = DEFAULT_STACK_SIZE;
53 luaD_init(L, stacksize); 54 luaD_init(L, stacksize);
54 luaS_init(L); 55 luaS_init(L);
55 luaX_init(L); 56 luaX_init(L);
@@ -61,31 +62,6 @@ static lua_State *newstate_aux (int stacksize, int put_builtin) {
61} 62}
62 63
63 64
64lua_State *lua_newstate (const char *s, ...) {
65 static const char *const ops[] = {"stack", "builtin", NULL};
66 va_list ap;
67 int stacksize = DEFAULT_STACK_SIZE;
68 int put_builtin = 1;
69 va_start(ap, s);
70 while (s) {
71 switch (luaL_findstring(s, ops)) {
72 case 0: /* stack */
73 stacksize = va_arg(ap, int);
74 break;
75 case 1: /* builtin */
76 put_builtin = va_arg(ap, int);
77 break;
78 default: /* invalid argument */
79 va_end(ap);
80 return NULL;
81 }
82 s = va_arg(ap, const char *);
83 }
84 va_end(ap);
85 return newstate_aux(stacksize, put_builtin);
86}
87
88
89void lua_close (lua_State *L) { 65void lua_close (lua_State *L) {
90 luaC_collect(L, 1); /* collect all elements */ 66 luaC_collect(L, 1); /* collect all elements */
91 LUA_ASSERT(L->rootproto == NULL, "list should be empty"); 67 LUA_ASSERT(L->rootproto == NULL, "list should be empty");