updates.
[silc.git] / apps / silcd / serverconfig.c
index eb743d834de81fe472f17e0f9dd1f3bfa01a8200..8a8aea500800cdd32d573cc359c3622f8df23617 100644 (file)
@@ -1195,11 +1195,11 @@ static void silc_server_config_set_defaults(SilcServerConfig config)
 }
 
 /* Allocates a new configuration object, opens configuration file and
- * parses it. The parsed data is returned to the newly allocated
- * configuration object. */
+   parses it. The parsed data is returned to the newly allocated
+   configuration object. The SilcServerConfig must be freed by calling
+   the silc_server_config_destroy function. */
 
-SilcServerConfig silc_server_config_alloc(SilcServer server,
-                                         const char *filename)
+SilcServerConfig silc_server_config_alloc(const char *filename)
 {
   SilcServerConfig config_new;
   SilcConfigEntity ent;
@@ -1265,7 +1265,7 @@ SilcServerConfig silc_server_config_alloc(SilcServer server,
   /* Set default to configuration parameters */
   silc_server_config_set_defaults(config_new);
 
-  silc_server_config_ref(&server->config_ref, config_new, config_new);
+  config_new->refcount = 1;
   return config_new;
 }
 
@@ -1288,14 +1288,8 @@ void silc_server_config_ref(SilcServerConfigRef *ref, SilcServerConfig config,
 
 void silc_server_config_unref(SilcServerConfigRef *ref)
 {
-  SilcServerConfig config = ref->config;
-  if (ref->ref_ptr) {
-    config->refcount--;
-    SILC_LOG_DEBUG(("Unreferencing config [%p] refcnt %hu->%hu", config,
-                   config->refcount + 1, config->refcount));
-    if (!config->refcount)
-      silc_server_config_destroy(config);
-  }
+  if (ref->ref_ptr)
+    silc_server_config_destroy(ref->config);
 }
 
 /* Destroy a config object with all his children lists */
@@ -1304,13 +1298,11 @@ void silc_server_config_destroy(SilcServerConfig config)
 {
   void *tmp;
 
-  if (config->refcount > 0) {
-    config->refcount--;
-    SILC_LOG_DEBUG(("Unreferencing config [%p] refcnt %hu->%hu", config,
-                   config->refcount + 1, config->refcount));
-    if (config->refcount > 0)
-      return;
-  }
+  config->refcount--;
+  SILC_LOG_DEBUG(("Unreferencing config [%p] refcnt %hu->%hu", config,
+                 config->refcount + 1, config->refcount));
+  if (config->refcount > 0)
+    return;
 
   SILC_LOG_DEBUG(("Freeing config context"));