summaryrefslogtreecommitdiff
path: root/src/lib/elua/elua.c
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2015-04-08 14:00:57 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2015-05-06 15:05:18 +0100
commitbf4837dbbfdb300372b9fe7a57378e580e4dad23 (patch)
tree2d4b9b94f5ff227431a79f6f08a74444c188b063 /src/lib/elua/elua.c
parente0917331f63d06805708243ab9e02958ab4b620f (diff)
elua lib: add elua_state_new and elua_state_free
Diffstat (limited to '')
-rw-r--r--src/lib/elua/elua.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/lib/elua/elua.c b/src/lib/elua/elua.c
index 2f88e7be02..a6bb3914cd 100644
--- a/src/lib/elua/elua.c
+++ b/src/lib/elua/elua.c
@@ -62,6 +62,27 @@ elua_shutdown(void)
62 return _elua_init_counter; 62 return _elua_init_counter;
63} 63}
64 64
65EAPI Elua_State *
66elua_state_new(void)
67{
68 Elua_State *ret = NULL;
69 lua_State *L = luaL_newstate();
70 if (!L)
71 return NULL;
72 ret = malloc(sizeof(Elua_State));
73 ret->luastate = L;
74 luaL_openlibs(L);
75 return ret;
76}
77
78EAPI void
79elua_state_free(Elua_State *state)
80{
81 if (!state) return;
82 if (state->luastate) lua_close(state->luastate);
83 free(state);
84}
85
65static void 86static void
66_elua_errmsg(const char *pname, const char *msg) 87_elua_errmsg(const char *pname, const char *msg)
67{ 88{