* @return {boolean} `true` if variable exists and has been removed
*/
LUA_FUNCTION_DEF (mempool, delete_variable);
+/**
+ * @method mempool:topointer()
+ *
+ * Returns raw C pointer (lightuserdata) associated with mempool. This might be
+ * broken with luajit and GC64, use with caution.
+ */
+LUA_FUNCTION_DEF (mempool, topointer);
static const struct luaL_reg mempoollib_m[] = {
LUA_INTERFACE_DEF (mempool, add_destructor),
LUA_INTERFACE_DEF (mempool, get_variable),
LUA_INTERFACE_DEF (mempool, has_variable),
LUA_INTERFACE_DEF (mempool, delete_variable),
+ LUA_INTERFACE_DEF (mempool, topointer),
LUA_INTERFACE_DEF (mempool, delete),
{"destroy", lua_mempool_delete},
{"__tostring", rspamd_lua_class_tostring},
return 1;
}
+static gint
+lua_mempool_topointer (lua_State *L)
+{
+ LUA_TRACE_POINT;
+ rspamd_mempool_t *pool = rspamd_lua_check_mempool (L, 1);
+
+ if (pool) {
+ /* XXX: this might cause issues on arm64 and LuaJIT */
+ lua_pushlightuserdata (L, pool);
+ }
+ else {
+ return luaL_error (L, "invalid arguments");
+ }
+
+ return 1;
+}
+
static gint
lua_load_mempool (lua_State * L)
{