diff --git a/include/haproxy/uri_auth.h b/include/haproxy/uri_auth.h index 27dca02c70..ae5dbb04a0 100644 --- a/include/haproxy/uri_auth.h +++ b/include/haproxy/uri_auth.h @@ -33,6 +33,7 @@ struct uri_auth *stats_add_auth(struct uri_auth **root, char *user); struct uri_auth *stats_add_scope(struct uri_auth **root, char *scope); struct uri_auth *stats_set_node(struct uri_auth **root, char *name); struct uri_auth *stats_set_desc(struct uri_auth **root, char *desc); +void stats_uri_auth_free(struct uri_auth *uri_auth); #endif /* _HAPROXY_URI_AUTH_H */ diff --git a/src/haproxy.c b/src/haproxy.c index 3496ba8151..56bd38b465 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -3283,35 +3283,9 @@ void deinit(void) proxy_destroy_all_unref_defaults(); while (ua) { - struct stat_scope *scope, *scopep; - struct stats_admin_rule *rule, *ruleb; - uap = ua; ua = ua->next; - - free(uap->uri_prefix); - free(uap->auth_realm); - free(uap->node); - free(uap->desc); - - userlist_free(uap->userlist); - free_act_rules(&uap->http_req_rules); - list_for_each_entry_safe(rule, ruleb, &uap->admin_rules, list) { - LIST_DELETE(&rule->list); - free_acl_cond(rule->cond); - free(rule); - } - - scope = uap->scope; - while (scope) { - scopep = scope; - scope = scope->next; - - free(scopep->px_id); - free(scopep); - } - - free(uap); + stats_uri_auth_free(uap); } userlist_free(userlist); diff --git a/src/uri_auth.c b/src/uri_auth.c index 979b327f6a..a487ed3755 100644 --- a/src/uri_auth.c +++ b/src/uri_auth.c @@ -13,7 +13,10 @@ #include #include +#include +#include #include +#include #include #include #include @@ -310,6 +313,35 @@ struct uri_auth *stats_add_scope(struct uri_auth **root, char *scope) return NULL; } +void stats_uri_auth_free(struct uri_auth *uri_auth) +{ + struct stat_scope *scope, *scopep; + struct stats_admin_rule *rule, *ruleb; + + free(uri_auth->uri_prefix); + free(uri_auth->auth_realm); + free(uri_auth->node); + free(uri_auth->desc); + + userlist_free(uri_auth->userlist); + free_act_rules(&uri_auth->http_req_rules); + list_for_each_entry_safe(rule, ruleb, &uri_auth->admin_rules, list) { + LIST_DELETE(&rule->list); + free_acl_cond(rule->cond); + free(rule); + } + + scope = uri_auth->scope; + while (scope) { + scopep = scope; + scope = scope->next; + free(scopep->px_id); + free(scopep); + } + + free(uri_auth); +} + /* * Local variables: * c-indent-level: 8