aboutsummaryrefslogtreecommitdiff
path: root/src/crypto.h
diff options
context:
space:
mode:
authoramelia squires <[email protected]>2024-09-16 12:16:29 -0500
committeramelia squires <[email protected]>2024-09-16 12:16:29 -0500
commit1feb3c40514a7c1726f29502ce37966c308bea79 (patch)
treed1a5a26af92af8fabf12d5095a2d3745431593b4 /src/crypto.h
parentdbf438f04dac63f2a32743fded1b7fbf02ed636b (diff)
fix _copy and mem leaks
Diffstat (limited to 'src/crypto.h')
-rw-r--r--src/crypto.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/crypto.h b/src/crypto.h
index b3b0609..ba97f0c 100644
--- a/src/crypto.h
+++ b/src/crypto.h
@@ -44,15 +44,16 @@ int tp(lua_State*);
#define common_hash_init_update(hashname) lua_common_hash_init_update(hashname, hashname)
#define lua_common_hash_init_update(hashname, luaname) lua_common_hash_init(hashname, luaname) lua_common_hash_update(hashname, luaname)
#define lua_common_hash_init(hashname, luaname) lua_common_hash_init_ni(hashname, luaname, hashname##_init())
+#define lua_common_hash_init_l(hashname, luaname) lua_common_hash_init_ni(hashname, luaname, hashname##_init_l(L))
#define common_hash_clone(hashname) lua_common_hash_clone(hashname, hashname)
-#define lua_common_hash_clone(hashname, luaname) lua_common_hash_clone_oargs(hashname, luaname, l_##luaname##_init(L))
-#define lua_common_hash_clone_oargs(hashname, luaname, oinit)\
+#define lua_common_hash_clone(hashname, luaname) lua_common_hash_clone_oargs(hashname, luaname, l_##luaname##_init(L), *b = *a)
+#define lua_common_hash_clone_oargs(hashname, luaname, oinit, copy)\
int l_##luaname##_clone(lua_State* L){\
struct hashname##_hash* a = (struct hashname##_hash*)lua_touserdata(L, -1);\
oinit;\
struct hashname##_hash* b = (struct hashname##_hash*)lua_touserdata(L, -1);\
- *b = *a;\
+ copy;\
return 1;\
}