From 01f83215a2ad235fbf306f591c6c0547b1bb7047 Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Thu, 15 Nov 2018 11:20:14 +0100 Subject: Deep userdata must embed DeepPrelude to save an allocation (also changes Deep protocol) --- src/linda.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/linda.c') diff --git a/src/linda.c b/src/linda.c index 98d2a8e..ee60ebc 100644 --- a/src/linda.c +++ b/src/linda.c @@ -46,6 +46,7 @@ THE SOFTWARE. */ struct s_Linda { + DeepPrelude prelude; // Deep userdata MUST start with this header SIGNAL_T read_happened; SIGNAL_T write_happened; Universe* U; // the universe this linda belongs to @@ -794,6 +795,7 @@ static void* linda_id( lua_State* L, DeepOp op_) s = (struct s_Linda*) malloc( sizeof(struct s_Linda) + name_len); // terminating 0 is already included if( s) { + s->prelude.magic.value = DEEP_VERSION.value; SIGNAL_INIT( &s->read_happened); SIGNAL_INIT( &s->write_happened); s->U = universe_get( L); @@ -895,8 +897,7 @@ static void* linda_id( lua_State* L, DeepOp op_) push_unique_key( L, NIL_SENTINEL); lua_setfield(L, -2, "null"); - luaG_pushdeepversion( L); - STACK_END( L, 2); + STACK_END( L, 1); return NULL; } -- cgit v1.2.3-55-g6feb