}
/* 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;
/* 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;
}
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 */
{
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"));