#include <freeradius-devel/util/atexit.h>
/*
- * Terminator for array of global_lib_autoinit_t
+ * Terminator for array of global_lib_autoinst_t
*/
-global_lib_autoinit_t const lib_autoinit_terminator = { .name = NULL };
+global_lib_autoinst_t const global_lib_terminator = { .name = NULL };
/*
* Global list of libraries
*/
typedef struct {
fr_rb_node_t entry; //!< Entry in tree of libraries
- global_lib_autoinit_t const *autoinit; //!< Autoinit structure used to manage this library
+ global_lib_autoinst_t const *autoinit; //!< Autoinit structure used to manage this library
uint32_t instance_count; //!< Number of current uses of this library
bool initialised; //!< Has the init callback been run for this library
} global_lib_inst_t;
* - 0 on succcess
* - -1 on failure
*/
-static int lib_auto_instantiate(global_lib_autoinit_t * const *to_init)
+static int lib_auto_instantiate(global_lib_autoinst_t * const *to_init)
{
- global_lib_autoinit_t * const *p;
+ global_lib_autoinst_t * const *p;
- for (p = to_init; *p != &lib_autoinit_terminator; p++) {
+ for (p = to_init; *p != &global_lib_terminator; p++) {
global_lib_inst_t *lib = NULL;
lib = fr_rb_find(&lib_list->libs, &(global_lib_inst_t){ .autoinit = *p });
*/
int global_lib_auto_instantiate(UNUSED dl_t const *module, void *symbol, UNUSED void *user_ctx)
{
- if (lib_auto_instantiate((global_lib_autoinit_t **)symbol) < 0) return -1;
+ if (lib_auto_instantiate((global_lib_autoinst_t **)symbol) < 0) return -1;
return 0;
}
*
* @param[in] to_free Array of autoinit structures detailing libraries to free
*/
-static void lib_autofree(global_lib_autoinit_t * const *to_free)
+static void lib_autofree(global_lib_autoinst_t * const *to_free)
{
- global_lib_autoinit_t * const *p;
+ global_lib_autoinst_t * const *p;
- for (p = to_free; *p != &lib_autoinit_terminator; p++) {
+ for (p = to_free; *p != &global_lib_terminator; p++) {
global_lib_inst_t *lib = NULL;
lib = fr_rb_find(&lib_list->libs, &(global_lib_inst_t){ .autoinit = *p });
*/
void global_lib_autofree(UNUSED dl_t const *module, void *symbol, UNUSED void *user_ctx)
{
- lib_autofree((global_lib_autoinit_t **)symbol);
+ lib_autofree((global_lib_autoinst_t **)symbol);
}
/** Compare two fr_lib_t
*/
int global_lib_init(void)
{
- if (lib_list) return;
+ if (lib_list) return 0;
MEM(lib_list = talloc_zero(NULL, global_lib_list_t));
fr_rb_inline_init(&lib_list->libs, global_lib_inst_t, entry, _lib_cmp, NULL);
void *inst; //!< Module data to parse global config into
lib_init_t init; //!< Callback to initialise library
lib_free_t free; //!< Callback to free library
-} global_lib_autoinit_t;
+} global_lib_autoinst_t;
+
+extern const global_lib_autoinst_t global_lib_terminator;
/*
- * To be used as terminator in an array of fr_lib_autoinit_t
+ * To be used as terminator in an array of global_lib_autoinst_t
*/
-extern const global_lib_autoinit_t lib_autoinit_terminator;
+#define GLOBAL_LIB_TERMINATOR &global_lib_terminator
int global_lib_auto_instantiate(dl_t const *module, void *symbol, void *user_ctx);