From b97fb932ece7872a8d1dd6c0a2c88f3ce33e9741 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 2 Oct 2003 17:31:17 -0300 Subject: Lua kernel does not use malloc/free functions. --- lauxlib.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'lauxlib.c') diff --git a/lauxlib.c b/lauxlib.c index 60e28646..b90bf458 100644 --- a/lauxlib.c +++ b/lauxlib.c @@ -1,5 +1,5 @@ /* -** $Id: lauxlib.c,v 1.102 2003/05/16 18:59:08 roberto Exp roberto $ +** $Id: lauxlib.c,v 1.103 2003/10/01 16:50:53 roberto Exp roberto $ ** Auxiliary functions for building Lua libraries ** See Copyright Notice in lua.h */ @@ -9,6 +9,7 @@ #include #include #include +#include #include @@ -558,6 +559,22 @@ LUALIB_API int luaL_loadbuffer (lua_State *L, const char *buff, size_t size, /* }====================================================== */ +static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) { + (void)ud; + if (nsize == 0) { + free(ptr); + return NULL; + } + else + return realloc(ptr, nsize); +} + + +LUALIB_API lua_State *luaL_newstate (void) { + return lua_newstate(l_alloc, NULL); +} + + /* ** {====================================================== ** compatibility code -- cgit v1.2.3-55-g6feb