Commit 1902ba0f authored by Vladimír Čunát's avatar Vladimír Čunát

lua module framework: reduce usage of void *data

Theoretically a lua module could have used them, but I see no motivation
for that, as they have much more convenient ways inside lua.
parent 63f5cb4d
......@@ -112,8 +112,7 @@ static int l_ffi_deinit(struct kr_module *module)
const int ret = l_ffi_modcb(L, module);
lua_pop(L, 1); /* the module's table */
/* Free the layer API wrapper (unconst it) */
kr_layer_api_t* api = module->data;
const kr_layer_api_t *api = module->layer;
if (!api) {
return ret;
}
......@@ -123,7 +122,7 @@ static int l_ffi_deinit(struct kr_module *module)
luaL_unref(L, LUA_REGISTRYINDEX, api->cb_slots[si]);
}
}
free(api);
free_const(api);
return ret;
}
......@@ -264,7 +263,6 @@ static kr_layer_api_t *l_ffi_layer_create(lua_State *L, struct kr_module *module
LAYER_REGISTER(L, api, checkout);
LAYER_REGISTER(L, api, answer_finalize);
LAYER_REGISTER(L, api, reset);
api->data = module;
}
return api;
}
......@@ -293,8 +291,6 @@ int ffimodule_register_lua(struct engine *engine, struct kr_module *module, cons
lua_getfield(L, -1, "layer");
if (!lua_isnil(L, -1)) {
module->layer = l_ffi_layer_create(L, module);
/* most likely not needed, but compatibility for now */
module->data = (void *)module->layer;
}
lua_pop(L, 1); /* .layer table */
......
......@@ -95,8 +95,7 @@ struct kr_layer_api {
* Last chance to affect what will get into the answer, including EDNS.*/
int (*answer_finalize)(kr_layer_t *ctx);
/** The module can store anything in here.
* In lua case we store kr_module pointer. */
/** The C module can store anything in here. */
void *data;
/** Internal to ./daemon/ffimodule.c. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment