From: Adam Dickmeiss Date: Thu, 11 Mar 2010 13:54:53 +0000 (+0100) Subject: Add database_hosts_destroy X-Git-Tag: v1.4.0~105 X-Git-Url: http://git.indexdata.com/?a=commitdiff_plain;h=2376c683c81f8352acb83f96d329dca7266f34c9;p=pazpar2-moved-to-github.git Add database_hosts_destroy --- 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