diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-10-02 17:31:17 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-10-02 17:31:17 -0300 |
commit | b97fb932ece7872a8d1dd6c0a2c88f3ce33e9741 (patch) | |
tree | d9e60044a35ad3fdf761f28506be08205081ebd7 /lauxlib.c | |
parent | c7cf92e6f318823406e40ad6016e5ccb4e041c72 (diff) | |
download | lua-b97fb932ece7872a8d1dd6c0a2c88f3ce33e9741.tar.gz lua-b97fb932ece7872a8d1dd6c0a2c88f3ce33e9741.tar.bz2 lua-b97fb932ece7872a8d1dd6c0a2c88f3ce33e9741.zip |
Lua kernel does not use malloc/free functions.
Diffstat (limited to 'lauxlib.c')
-rw-r--r-- | lauxlib.c | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lauxlib.c,v 1.102 2003/05/16 18:59:08 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.103 2003/10/01 16:50:53 roberto Exp roberto $ |
3 | ** Auxiliary functions for building Lua libraries | 3 | ** Auxiliary functions for building Lua libraries |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -9,6 +9,7 @@ | |||
9 | #include <errno.h> | 9 | #include <errno.h> |
10 | #include <stdarg.h> | 10 | #include <stdarg.h> |
11 | #include <stdio.h> | 11 | #include <stdio.h> |
12 | #include <stdlib.h> | ||
12 | #include <string.h> | 13 | #include <string.h> |
13 | 14 | ||
14 | 15 | ||
@@ -558,6 +559,22 @@ LUALIB_API int luaL_loadbuffer (lua_State *L, const char *buff, size_t size, | |||
558 | /* }====================================================== */ | 559 | /* }====================================================== */ |
559 | 560 | ||
560 | 561 | ||
562 | static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) { | ||
563 | (void)ud; | ||
564 | if (nsize == 0) { | ||
565 | free(ptr); | ||
566 | return NULL; | ||
567 | } | ||
568 | else | ||
569 | return realloc(ptr, nsize); | ||
570 | } | ||
571 | |||
572 | |||
573 | LUALIB_API lua_State *luaL_newstate (void) { | ||
574 | return lua_newstate(l_alloc, NULL); | ||
575 | } | ||
576 | |||
577 | |||
561 | /* | 578 | /* |
562 | ** {====================================================== | 579 | ** {====================================================== |
563 | ** compatibility code | 580 | ** compatibility code |