diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-10-20 10:25:23 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-10-20 10:25:23 -0200 |
commit | 03bab90303270534ba6a415b5379d4659757082d (patch) | |
tree | 06ca47214b7503990508e6814fa73e00638f81ff | |
parent | 8502331f69a3a13bce0b2afca36dd3f607eb3696 (diff) | |
download | lua-03bab90303270534ba6a415b5379d4659757082d.tar.gz lua-03bab90303270534ba6a415b5379d4659757082d.tar.bz2 lua-03bab90303270534ba6a415b5379d4659757082d.zip |
new function `lua_getallocf' to retrieve allocation function and data
-rw-r--r-- | lapi.c | 10 | ||||
-rw-r--r-- | ltests.c | 5 | ||||
-rw-r--r-- | lua.h | 4 |
3 files changed, 16 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 1.246 2003/10/10 12:57:55 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.247 2003/10/10 13:29:08 roberto Exp roberto $ |
3 | ** Lua API | 3 | ** Lua API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -882,6 +882,12 @@ LUA_API void lua_concat (lua_State *L, int n) { | |||
882 | } | 882 | } |
883 | 883 | ||
884 | 884 | ||
885 | LUA_API lua_Alloc lua_getallocf (lua_State *L, void **ud) { | ||
886 | *ud = G(L)->ud; | ||
887 | return G(L)->realloc; | ||
888 | } | ||
889 | |||
890 | |||
885 | LUA_API void *lua_newuserdata (lua_State *L, size_t size) { | 891 | LUA_API void *lua_newuserdata (lua_State *L, size_t size) { |
886 | Udata *u; | 892 | Udata *u; |
887 | lua_lock(L); | 893 | lua_lock(L); |
@@ -894,6 +900,8 @@ LUA_API void *lua_newuserdata (lua_State *L, size_t size) { | |||
894 | } | 900 | } |
895 | 901 | ||
896 | 902 | ||
903 | |||
904 | |||
897 | static const char *aux_upvalue (lua_State *L, int funcindex, int n, | 905 | static const char *aux_upvalue (lua_State *L, int funcindex, int n, |
898 | TObject **val) { | 906 | TObject **val) { |
899 | Closure *f; | 907 | Closure *f; |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltests.c,v 1.165 2003/10/07 20:13:41 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 1.166 2003/10/10 13:29:08 roberto Exp roberto $ |
3 | ** Internal Module for Debugging of the Lua Implementation | 3 | ** Internal Module for Debugging of the Lua Implementation |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -836,6 +836,9 @@ static int l_panic (lua_State *L) { | |||
836 | 836 | ||
837 | 837 | ||
838 | int luaB_opentests (lua_State *L) { | 838 | int luaB_opentests (lua_State *L) { |
839 | void *ud; | ||
840 | lua_assert(lua_getallocf(L, &ud) == debug_realloc); | ||
841 | lua_assert(ud == cast(void *, &memcontrol)); | ||
839 | lua_atpanic(L, l_panic); | 842 | lua_atpanic(L, l_panic); |
840 | lua_userstateopen(L); /* init lock */ | 843 | lua_userstateopen(L); /* init lock */ |
841 | lua_state = L; /* keep first state to be opened */ | 844 | lua_state = L; /* keep first state to be opened */ |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.h,v 1.181 2003/10/10 12:57:55 roberto Exp roberto $ | 2 | ** $Id: lua.h,v 1.182 2003/10/10 13:29:08 roberto Exp roberto $ |
3 | ** Lua - An Extensible Extension Language | 3 | ** Lua - An Extensible Extension Language |
4 | ** Tecgraf: Computer Graphics Technology Group, PUC-Rio, Brazil | 4 | ** Tecgraf: Computer Graphics Technology Group, PUC-Rio, Brazil |
5 | ** http://www.lua.org mailto:info@lua.org | 5 | ** http://www.lua.org mailto:info@lua.org |
@@ -239,6 +239,8 @@ LUA_API int lua_next (lua_State *L, int idx); | |||
239 | 239 | ||
240 | LUA_API void lua_concat (lua_State *L, int n); | 240 | LUA_API void lua_concat (lua_State *L, int n); |
241 | 241 | ||
242 | LUA_API lua_Alloc lua_getallocf (lua_State *L, void **ud); | ||
243 | |||
242 | 244 | ||
243 | 245 | ||
244 | /* | 246 | /* |