From 2376c683c81f8352acb83f96d329dca7266f34c9 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 11 Mar 2010 14:54:53 +0100 Subject: [PATCH] Add database_hosts_destroy --- src/database.c | 19 +++++++++++++++++++ src/database.h | 1 + 2 files changed, 20 insertions(+) diff --git a/src/database.c b/src/database.c index 8ffbee2..42b3c3a 100644 --- a/src/database.c +++ b/src/database.c @@ -414,6 +414,25 @@ database_hosts_t database_hosts_create(void) return p; } +void database_hosts_destroy(database_hosts_t *pp) +{ + if (*pp) + { + struct host *p = (*pp)->hosts; + while (p) + { + struct host *p_next = p->next; + yaz_mutex_destroy(&p->mutex); + xfree(p->ipport); + xfree(p->hostport); + xfree(p); + p = p_next; + } + yaz_mutex_destroy(&(*pp)->mutex); + xfree(*pp); + } +} + /* * Local variables: * c-basic-offset: 4 diff --git a/src/database.h b/src/database.h index aabf394..72b5f64 100644 --- a/src/database.h +++ b/src/database.h @@ -33,4 +33,5 @@ int resolve_database(struct conf_service *service, struct database *db); struct database *new_database(const char *id, NMEM nmem); database_hosts_t database_hosts_create(void); +void database_hosts_destroy(database_hosts_t *); #endif -- 1.7.10.4