aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lua.c6
-rw-r--r--src/lua.h1
-rw-r--r--src/thread.c2
3 files changed, 8 insertions, 1 deletions
diff --git a/src/lua.c b/src/lua.c
index f0240b3..45ceeb9 100644
--- a/src/lua.c
+++ b/src/lua.c
@@ -287,6 +287,12 @@ void luaI_deepcopy(lua_State* src, lua_State* dest, enum deep_copy_flags flags){
lua_setmetatable(dest, tidx);
lua_settop(dest, tidx);
+
+ if(flags & STRIP_GC){
+ int sidx = lua_gettop(src);
+ lua_getmetatable(src, sidx);
+ luaI_tsetnil(src, sidx, "__gc");
+ }
}
lua_settop(src, old_top);
}
diff --git a/src/lua.h b/src/lua.h
index 8fc934c..1ae8820 100644
--- a/src/lua.h
+++ b/src/lua.h
@@ -14,6 +14,7 @@ enum deep_copy_flags {
IS_META = (1 << 2),
SKIP__G = (1 << 3),
SKIP_LOCALS = (1 << 4),
+ STRIP_GC = (1 << 5),
};
#endif
diff --git a/src/thread.c b/src/thread.c
index 9b9ddb2..50b55cf 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -532,7 +532,7 @@ int l_buffer(lua_State* L){
buffer->lock = malloc(sizeof * buffer->lock);
if(pthread_mutex_init(&*buffer->lock, NULL) != 0) p_fatal("pthread_mutex_init failed");
lua_pushvalue(L, 1);
- luaI_deepcopy(L, buffer->L, SKIP_LOCALS);
+ luaI_deepcopy(L, buffer->L, SKIP_LOCALS | STRIP_GC);
lua_newtable(L);
int meta_idx = lua_gettop(L);