]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Rename some more global_lib functions
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 2 Jun 2022 17:41:31 +0000 (13:41 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 2 Jun 2022 17:41:31 +0000 (13:41 -0400)
src/lib/server/global_lib.c
src/lib/server/global_lib.h

index 8cc37a3e4da121d11fcc0c5a620d202c35671be2..9d561349f492d1c539f986c8608f07c287f52e6e 100644 (file)
@@ -27,9 +27,9 @@
 #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
@@ -45,7 +45,7 @@ static global_lib_list_t *lib_list;
  */
 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;
@@ -95,11 +95,11 @@ static int lib_init_call(global_lib_inst_t *lib)
  *     - 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 });
@@ -136,7 +136,7 @@ static int lib_auto_instantiate(global_lib_autoinit_t * const *to_init)
  */
 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;
 }
@@ -145,11 +145,11 @@ int global_lib_auto_instantiate(UNUSED dl_t const *module, void *symbol, UNUSED
  *
  * @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 });
@@ -173,7 +173,7 @@ static void lib_autofree(global_lib_autoinit_t * const *to_free)
  */
 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
@@ -203,7 +203,7 @@ static int _lib_list_free_atexit(UNUSED void *uctx)
  */
 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);
index bb7ea55515e8cbc8a926e38941b9bff67068db90..ce07a54789acbef1c483cbc1a0c41d807032fe8c 100644 (file)
@@ -41,12 +41,14 @@ typedef struct {
        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);