From 46730eb47d0d736998a0ebcad4d8f1318fefd096 Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Mon, 7 Feb 2022 16:34:47 +0100 Subject: A Lane's Lua state uses the Universe-defined allocator by default --- src/state.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/state.c b/src/state.c index 9075c02..c6c04d7 100644 --- a/src/state.c +++ b/src/state.c @@ -249,7 +249,7 @@ void initialize_on_state_create( Universe* U, lua_State* L) lua_State* create_state( Universe* U, lua_State* from_) { lua_State* L; - if( U->provide_allocator != NULL) + if( U->provide_allocator != NULL) // we have a function we can call to obtain an allocator { lua_pushcclosure( from_, U->provide_allocator, 0); lua_call( from_, 0, 1); @@ -261,7 +261,8 @@ lua_State* create_state( Universe* U, lua_State* from_) } else { - L = luaL_newstate(); + // reuse the allocator provided when the master state was created + L = lua_newstate( U->protected_allocator.definition.allocF, U->protected_allocator.definition.allocUD); } if( L == NULL) -- cgit v1.2.3-55-g6feb