From: wessels <> Date: Fri, 11 Oct 1996 01:04:14 +0000 (+0000) Subject: More xxFreeMemory() functions and fixes X-Git-Tag: SQUID_3_0_PRE1~5685 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=56e15c50d6935ab7e386b0b375fbed8f5a3e15ae;p=thirdparty%2Fsquid.git More xxFreeMemory() functions and fixes --- diff --git a/src/fqdncache.cc b/src/fqdncache.cc index 2f41b9f208..b70213368f 100644 --- a/src/fqdncache.cc +++ b/src/fqdncache.cc @@ -1,6 +1,6 @@ /* - * $Id: fqdncache.cc,v 1.22 1996/10/09 15:34:25 wessels Exp $ + * $Id: fqdncache.cc,v 1.23 1996/10/10 19:04:14 wessels Exp $ * * DEBUG: section 35 FQDN Cache * AUTHOR: Harvest Derived @@ -872,3 +872,30 @@ fqdncacheQueueDrain(void) fqdncache_dnsDispatch(dnsData, i); return 1; } + +void +fqdncacheFreeMemory(void) +{ + fqdncache_entry *f; + fqdncache_entry **list; + int k = 0; + int j; + list = xcalloc(meta_data.fqdncache_count, sizeof(fqdncache_entry *)); + f = (fqdncache_entry *) hash_first(fqdn_table); + while (f && k < meta_data.fqdncache_count) { + *(list + k) = f; + k++; + f = (fqdncache_entry *) hash_next(fqdn_table); + } + for (j = 0; j < k; j++) { + f = *(list + j); + for (k = 0; k < (int) f->name_count; k++) + safe_free(f->names[k]); + safe_free(f->name); + safe_free(f->error_message); + safe_free(f); + } + xfree(list); + hashFreeMemory(fqdn_table); +} + diff --git a/src/ipcache.cc b/src/ipcache.cc index 5c6fc57d75..a6c0c3838d 100644 --- a/src/ipcache.cc +++ b/src/ipcache.cc @@ -1,5 +1,5 @@ /* - * $Id: ipcache.cc,v 1.68 1996/10/09 22:49:37 wessels Exp $ + * $Id: ipcache.cc,v 1.69 1996/10/10 19:04:16 wessels Exp $ * * DEBUG: section 14 IP Cache * AUTHOR: Harvest Derived @@ -1010,3 +1010,28 @@ ipcacheRemoveBadAddr(char *name, struct in_addr addr) if (ia->cur >= ia->count) ia->cur = 0; } + +void +ipcacheFreeMemory(void) +{ + ipcache_entry *i; + ipcache_entry **list; + int k = 0; + int j; + list = xcalloc(meta_data.ipcache_count, sizeof(ipcache_entry *)); + i = (ipcache_entry *) hash_first(ip_table); + while (i && k < meta_data.ipcache_count) { + *(list + k) = i; + k++; + i = (ipcache_entry *) hash_next(ip_table); + } + for (j = 0; j < k; j++) { + i = *(list + j); + safe_free(i->addrs.in_addrs); + safe_free(i->name); + safe_free(i->error_message); + safe_free(i); + } + xfree(list); + hashFreeMemory(ip_table); +} diff --git a/src/net_db.cc b/src/net_db.cc index 90cba5cd04..ed5460b6b3 100644 --- a/src/net_db.cc +++ b/src/net_db.cc @@ -310,7 +310,7 @@ netdbFreeMemory(void) int i = 0; int j; - L1 = xcalloc(meta_data.netdb_addrs, sizeof(netdbEntry)); + L1 = xcalloc(meta_data.netdb_addrs, sizeof(netdbEntry *)); n = (netdbEntry *) hash_first(addr_table); while (n && i < meta_data.netdb_addrs) { *(L1 + i) = n; @@ -328,7 +328,7 @@ netdbFreeMemory(void) xfree(L1); i = 0; - L2 = xcalloc(meta_data.netdb_hosts, sizeof(netdbEntry)); + L2 = xcalloc(meta_data.netdb_hosts, sizeof(hash_link *)); h = hash_first(host_table); while (h && i < meta_data.netdb_hosts) { *(L2 + i) = h; diff --git a/src/store.cc b/src/store.cc index b46d6735ee..35ceb5e250 100644 --- a/src/store.cc +++ b/src/store.cc @@ -1,6 +1,6 @@ /* - * $Id: store.cc,v 1.128 1996/10/10 18:52:23 wessels Exp $ + * $Id: store.cc,v 1.129 1996/10/10 19:04:19 wessels Exp $ * * DEBUG: section 20 Storeage Manager * AUTHOR: Harvest Derived @@ -2875,7 +2875,7 @@ storeFreeMemory(void) StoreEntry **list; int i = 0; int j; - list = xcalloc(meta_data.store_entries, sizeof(StoreEntry)); + list = xcalloc(meta_data.store_entries, sizeof(StoreEntry *)); e = (StoreEntry *) hash_first(store_table); while (e && i < meta_data.store_entries) { *(list + i) = e; diff --git a/src/tools.cc b/src/tools.cc index fef61fda04..9b68f6d5c8 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -1,6 +1,6 @@ /* - * $Id: tools.cc,v 1.68 1996/10/09 22:49:44 wessels Exp $ + * $Id: tools.cc,v 1.69 1996/10/10 19:04:20 wessels Exp $ * * DEBUG: section 21 Misc Functions * AUTHOR: Harvest Derived @@ -309,6 +309,8 @@ normal_shutdown(void) errorpageFreeMemory(); stmemFreeMemory(); netdbFreeMemory(); + ipcacheFreeMemory(); + fqdncacheFreeMemory(); debug(21, 0, "Squid Cache (Version %s): Exiting normally.\n", version_string); exit(0);