mirror of
https://github.com/lua/lua
synced 2025-02-24 00:54:06 +03:00
new function 'lua_setallocf'
This commit is contained in:
parent
bf96d3fdd9
commit
d8f1cca16e
16
lapi.c
16
lapi.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lapi.c,v 2.48 2005/09/01 17:42:22 roberto Exp roberto $
|
||||
** $Id: lapi.c,v 2.49 2005/09/14 17:44:48 roberto Exp roberto $
|
||||
** Lua API
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -992,8 +992,20 @@ LUA_API void lua_concat (lua_State *L, int n) {
|
||||
|
||||
|
||||
LUA_API lua_Alloc lua_getallocf (lua_State *L, void **ud) {
|
||||
lua_Alloc f;
|
||||
lua_lock(L);
|
||||
if (ud) *ud = G(L)->ud;
|
||||
return G(L)->frealloc;
|
||||
f = G(L)->frealloc;
|
||||
lua_unlock(L);
|
||||
return f;
|
||||
}
|
||||
|
||||
|
||||
LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud) {
|
||||
lua_lock(L);
|
||||
G(L)->ud = ud;
|
||||
G(L)->frealloc = f;
|
||||
lua_unlock(L);
|
||||
}
|
||||
|
||||
|
||||
|
3
ltests.c
3
ltests.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: ltests.c,v 2.30 2005/08/26 17:36:32 roberto Exp roberto $
|
||||
** $Id: ltests.c,v 2.31 2005/09/14 17:48:57 roberto Exp roberto $
|
||||
** Internal Module for Debugging of the Lua Implementation
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -1124,6 +1124,7 @@ int luaB_opentests (lua_State *L) {
|
||||
void *ud;
|
||||
lua_assert(lua_getallocf(L, &ud) == debug_realloc);
|
||||
lua_assert(ud == cast(void *, &memcontrol));
|
||||
lua_setallocf(L, lua_getallocf(L, NULL), ud);
|
||||
lua_state = L; /* keep first state to be opened */
|
||||
luaL_register(L, "T", tests_funcs);
|
||||
return 0;
|
||||
|
3
lua.h
3
lua.h
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lua.h,v 1.211 2005/08/12 13:34:15 roberto Exp roberto $
|
||||
** $Id: lua.h,v 1.212 2005/08/25 20:02:08 roberto Exp roberto $
|
||||
** Lua - An Extensible Extension Language
|
||||
** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
|
||||
** See Copyright Notice at the end of this file
|
||||
@ -239,6 +239,7 @@ LUA_API int (lua_next) (lua_State *L, int idx);
|
||||
LUA_API void (lua_concat) (lua_State *L, int n);
|
||||
|
||||
LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud);
|
||||
LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud);
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user