changeset 6417:047d0d8bbf0a HEAD

hash_destroy() and hash_iterate_deinit() now take ** pointer.
author Timo Sirainen <tss@iki.fi>
date Sun, 16 Sep 2007 12:35:01 +0300
parents 298e651e18de
children 46d9ee79f292
files src/auth/auth-cache.c src/auth/auth-request-handler.c src/auth/db-ldap.c src/auth/db-passwd-file.c src/auth/passdb-checkpassword.c src/deliver/duplicate.c src/dict/dict-cache.c src/imap-login/client.c src/imap/imap-thread.c src/lib-auth/auth-server-connection.c src/lib-auth/auth-server-request.c src/lib-index/mail-cache.c src/lib-index/mail-index.c src/lib-storage/index/dbox/dbox-sync.c src/lib-storage/index/maildir/maildir-keywords.c src/lib-storage/index/maildir/maildir-uidlist.c src/lib/hash.c src/lib/hash.h src/login-common/login-proxy.c src/login-common/master.c src/login-common/ssl-proxy-openssl.c src/master/auth-process.c src/master/child-process.c src/master/login-process.c src/master/mail-process.c src/plugins/acl/acl-cache.c src/pop3-login/client.c
diffstat 27 files changed, 67 insertions(+), 69 deletions(-) [+]
line wrap: on
line diff
--- a/src/auth/auth-cache.c	Sun Sep 16 12:31:27 2007 +0300
+++ b/src/auth/auth-cache.c	Sun Sep 16 12:35:01 2007 +0300
@@ -139,7 +139,7 @@
 	lib_signals_unset_handler(SIGUSR2, sig_auth_cache_stats, cache);
 
 	auth_cache_clear(cache);
-	hash_destroy(cache->hash);
+	hash_destroy(&cache->hash);
 	i_free(cache);
 }
 
--- a/src/auth/auth-request-handler.c	Sun Sep 16 12:31:27 2007 +0300
+++ b/src/auth/auth-request-handler.c	Sun Sep 16 12:35:01 2007 +0300
@@ -69,12 +69,12 @@
 
 		auth_request_unref(&auth_request);
 	}
-	hash_iterate_deinit(iter);
+	hash_iterate_deinit(&iter);
 
 	/* notify parent that we're done with all requests */
 	handler->callback(NULL, handler->context);
 
-	hash_destroy(handler->requests);
+	hash_destroy(&handler->requests);
 	pool_unref(handler->pool);
 }
 
@@ -105,7 +105,7 @@
 		if (request->last_access + AUTH_REQUEST_TIMEOUT < ioloop_time)
 			auth_request_handler_remove(handler, request);
 	}
-	hash_iterate_deinit(iter);
+	hash_iterate_deinit(&iter);
 }
 
 static const char *get_client_extra_fields(struct auth_request *request)
--- a/src/auth/db-ldap.c	Sun Sep 16 12:31:27 2007 +0300
+++ b/src/auth/db-ldap.c	Sun Sep 16 12:35:01 2007 +0300
@@ -310,7 +310,7 @@
 			db_ldap_search(conn, request, conn->set.ldap_scope);
 		}
 	}
-	hash_iterate_deinit(iter);
+	hash_iterate_deinit(&iter);
 
 	/* then delayed search requests */
 	p = &conn->delayed_requests_head;
@@ -338,7 +338,7 @@
 			if (request->filter == NULL)
 				request->callback(conn, request, NULL);
 		}
-		hash_iterate_deinit(iter);
+		hash_iterate_deinit(&iter);
 	}
 	if (conn->delayed_requests_head != NULL && conn->set.auth_bind) {
 		request = conn->delayed_requests_head;
@@ -350,7 +350,7 @@
 		}
 		conn->delayed_requests_head = NULL;
 	}
-	hash_destroy(old_requests);
+	hash_destroy(&old_requests);
 
 	i_assert(conn->delayed_requests_head == NULL);
 	conn->delayed_requests_tail = NULL;
@@ -632,7 +632,7 @@
 
 			request->callback(conn, request, NULL);
 		}
-		hash_iterate_deinit(iter);
+		hash_iterate_deinit(&iter);
 		hash_clear(conn->requests, FALSE);
 
 		request = conn->delayed_requests_head;
@@ -1006,11 +1006,11 @@
 
 	ldap_conn_close(conn, TRUE);
 
-	hash_destroy(conn->requests);
+	hash_destroy(&conn->requests);
 	if (conn->pass_attr_map != NULL)
-		hash_destroy(conn->pass_attr_map);
+		hash_destroy(&conn->pass_attr_map);
 	if (conn->user_attr_map != NULL)
-		hash_destroy(conn->user_attr_map);
+		hash_destroy(&conn->user_attr_map);
 	pool_unref(conn->pool);
 }
 
--- a/src/auth/db-passwd-file.c	Sun Sep 16 12:31:27 2007 +0300
+++ b/src/auth/db-passwd-file.c	Sun Sep 16 12:35:01 2007 +0300
@@ -216,10 +216,8 @@
 		pw->fd = -1;
 	}
 
-	if (pw->users != NULL) {
-		hash_destroy(pw->users);
-		pw->users = NULL;
-	}
+	if (pw->users != NULL)
+		hash_destroy(&pw->users);
 	if (pw->pool != NULL) {
 		pool_unref(pw->pool);
 		pw->pool = NULL;
@@ -362,8 +360,8 @@
 
 			passwd_file_free(file);
 		}
-		hash_iterate_deinit(iter);
-		hash_destroy(db->files);
+		hash_iterate_deinit(&iter);
+		hash_destroy(&db->files);
 	}
 	i_free(db->path);
 	i_free(db);
--- a/src/auth/passdb-checkpassword.c	Sun Sep 16 12:31:27 2007 +0300
+++ b/src/auth/passdb-checkpassword.c	Sun Sep 16 12:35:01 2007 +0300
@@ -455,8 +455,8 @@
 		checkpassword_request_finish(value,
 					     PASSDB_RESULT_INTERNAL_FAILURE);
 	}
-	hash_iterate_deinit(iter);
-	hash_destroy(module->clients);
+	hash_iterate_deinit(&iter);
+	hash_destroy(&module->clients);
 }
 
 struct passdb_module_interface passdb_checkpassword = {
--- a/src/deliver/duplicate.c	Sun Sep 16 12:31:27 2007 +0300
+++ b/src/deliver/duplicate.c	Sun Sep 16 12:35:01 2007 +0300
@@ -168,7 +168,7 @@
 	if (file->dotlock != NULL)
 		file_dotlock_delete(&file->dotlock);
 
-	hash_destroy(file->hash);
+	hash_destroy(&file->hash);
 	pool_unref(file->pool);
 }
 
@@ -230,7 +230,7 @@
 		o_stream_send(output, d->id, d->id_size);
 		o_stream_send(output, d->user, user_size);
 	}
-	hash_iterate_deinit(iter);
+	hash_iterate_deinit(&iter);
 	o_stream_unref(&output);
 
 	file->changed = FALSE;
--- a/src/dict/dict-cache.c	Sun Sep 16 12:31:27 2007 +0300
+++ b/src/dict/dict-cache.c	Sun Sep 16 12:35:01 2007 +0300
@@ -27,7 +27,7 @@
 
 void dict_cache_deinit(struct dict_cache *cache)
 {
-	hash_destroy(cache->dicts);
+	hash_destroy(&cache->dicts);
 	i_free(cache);
 }
 
--- a/src/imap-login/client.c	Sun Sep 16 12:31:27 2007 +0300
+++ b/src/imap-login/client.c	Sun Sep 16 12:35:01 2007 +0300
@@ -384,7 +384,7 @@
 			}
 		}
 	}
-	hash_iterate_deinit(iter);
+	hash_iterate_deinit(&iter);
 
 	/* then kill them */
 	for (i = 0; i < destroy_count; i++) {
@@ -590,7 +590,7 @@
 
 		client_check_idle(client);
 	}
-	hash_iterate_deinit(iter);
+	hash_iterate_deinit(&iter);
 }
 
 unsigned int clients_get_count(void)
@@ -614,7 +614,7 @@
 			client_input(client);
 		}
 	}
-	hash_iterate_deinit(iter);
+	hash_iterate_deinit(&iter);
 }
 
 void clients_destroy_all(void)
@@ -628,7 +628,7 @@
 
 		client_destroy(client, "Disconnected: Shutting down");
 	}
-	hash_iterate_deinit(iter);
+	hash_iterate_deinit(&iter);
 }
 
 void clients_init(void)
@@ -639,7 +639,7 @@
 void clients_deinit(void)
 {
 	clients_destroy_all();
-	hash_destroy(clients);
+	hash_destroy(&clients);
 
 	i_assert(to_idle == NULL);
 }
--- a/src/imap/imap-thread.c	Sun Sep 16 12:31:27 2007 +0300
+++ b/src/imap/imap-thread.c	Sun Sep 16 12:35:01 2007 +0300
@@ -93,9 +93,9 @@
 static void mail_thread_deinit(struct thread_context *ctx)
 {
 	if (ctx->msgid_hash != NULL)
-		hash_destroy(ctx->msgid_hash);
+		hash_destroy(&ctx->msgid_hash);
 	if (ctx->subject_hash != NULL)
-		hash_destroy(ctx->subject_hash);
+		hash_destroy(&ctx->subject_hash);
 
 	pool_unref(ctx->temp_pool);
 	pool_unref(ctx->pool);
@@ -940,13 +940,11 @@
 		if (node->parent == NULL)
 			add_root(ctx, node);
 	}
-	hash_iterate_deinit(iter);
+	hash_iterate_deinit(&iter);
 
 	/* drop the memory allocated for message-IDs and msgid_hash,
 	   reuse their memory for base subjects */
-	hash_destroy(ctx->msgid_hash);
-	ctx->msgid_hash = NULL;
-
+	hash_destroy(&ctx->msgid_hash);
 	p_clear(ctx->temp_pool);
 
 	if (ctx->root_node.first_child == NULL) {
--- a/src/lib-auth/auth-server-connection.c	Sun Sep 16 12:31:27 2007 +0300
+++ b/src/lib-auth/auth-server-connection.c	Sun Sep 16 12:35:01 2007 +0300
@@ -301,7 +301,7 @@
 		return;
 	i_assert(conn->refcount == 0);
 
-	hash_destroy(conn->requests);
+	hash_destroy(&conn->requests);
 	buffer_free(&conn->auth_mechs_buf);
 
 	i_stream_unref(&conn->input);
--- a/src/lib-auth/auth-server-request.c	Sun Sep 16 12:31:27 2007 +0300
+++ b/src/lib-auth/auth-server-request.c	Sun Sep 16 12:35:01 2007 +0300
@@ -314,7 +314,7 @@
 	iter = hash_iterate_init(conn->requests);
 	while (hash_iterate(iter, &key, &value))
 		request_hash_remove(conn, value);
-	hash_iterate_deinit(iter);
+	hash_iterate_deinit(&iter);
 }
 
 struct auth_request *
--- a/src/lib-index/mail-cache.c	Sun Sep 16 12:31:27 2007 +0300
+++ b/src/lib-index/mail-cache.c	Sun Sep 16 12:35:01 2007 +0300
@@ -392,7 +392,7 @@
 
 	mail_cache_file_close(cache);
 
-	hash_destroy(cache->field_name_hash);
+	hash_destroy(&cache->field_name_hash);
 	pool_unref(cache->field_pool);
 	i_free(cache->field_file_map);
 	i_free(cache->file_field_map);
--- a/src/lib-index/mail-index.c	Sun Sep 16 12:31:27 2007 +0300
+++ b/src/lib-index/mail-index.c	Sun Sep 16 12:35:01 2007 +0300
@@ -61,7 +61,7 @@
 	mail_index_close(index);
 
 	mail_transaction_log_free(&index->log);
-	hash_destroy(index->keywords_hash);
+	hash_destroy(&index->keywords_hash);
 	pool_unref(index->extension_pool);
 	pool_unref(index->keywords_pool);
 
--- a/src/lib-storage/index/dbox/dbox-sync.c	Sun Sep 16 12:31:27 2007 +0300
+++ b/src/lib-storage/index/dbox/dbox-sync.c	Sun Sep 16 12:35:01 2007 +0300
@@ -211,7 +211,7 @@
 			if ((ret = dbox_sync_file(ctx, entry)) <= 0)
 				break;
 		}
-		hash_iterate_deinit(iter);
+		hash_iterate_deinit(&iter);
 	}
 
 	if (ret > 0)
@@ -221,7 +221,7 @@
 		box->v.sync_notify(box, 0, 0);
 
 	dbox_sync_unlock_files(ctx);
-	hash_destroy(ctx->syncs);
+	hash_destroy(&ctx->syncs);
 	pool_unref(ctx->pool);
 	return ret;
 }
--- a/src/lib-storage/index/maildir/maildir-keywords.c	Sun Sep 16 12:31:27 2007 +0300
+++ b/src/lib-storage/index/maildir/maildir-keywords.c	Sun Sep 16 12:35:01 2007 +0300
@@ -88,7 +88,7 @@
 	struct maildir_keywords *mk = *_mk;
 
 	*_mk = NULL;
-	hash_destroy(mk->hash);
+	hash_destroy(&mk->hash);
 	array_free(&mk->list);
 	pool_unref(mk->pool);
 	i_free(mk->path);
--- a/src/lib-storage/index/maildir/maildir-uidlist.c	Sun Sep 16 12:31:27 2007 +0300
+++ b/src/lib-storage/index/maildir/maildir-uidlist.c	Sun Sep 16 12:35:01 2007 +0300
@@ -239,7 +239,7 @@
 	*_uidlist = NULL;
 	maildir_uidlist_close(uidlist);
 
-	hash_destroy(uidlist->files);
+	hash_destroy(&uidlist->files);
 	if (uidlist->record_pool != NULL)
 		pool_unref(uidlist->record_pool);
 
@@ -1242,7 +1242,7 @@
 	uidlist->records = ctx->records;
 	ctx->records.arr.buffer = NULL;
 
-	hash_destroy(uidlist->files);
+	hash_destroy(&uidlist->files);
 	uidlist->files = ctx->files;
 	ctx->files = NULL;
 
@@ -1295,7 +1295,7 @@
 	maildir_uidlist_unlock(ctx->uidlist);
 
 	if (ctx->files != NULL)
-		hash_destroy(ctx->files);
+		hash_destroy(&ctx->files);
 	if (ctx->record_pool != NULL)
 		pool_unref(ctx->record_pool);
 	if (array_is_created(&ctx->records))
--- a/src/lib/hash.c	Sun Sep 16 12:31:27 2007 +0300
+++ b/src/lib/hash.c	Sun Sep 16 12:35:01 2007 +0300
@@ -101,7 +101,7 @@
 	}
 }
 
-void _hash_destroy(struct hash_table **_table)
+void hash_destroy(struct hash_table **_table)
 {
 	struct hash_table *table = *_table;
 
@@ -376,8 +376,11 @@
 	return TRUE;
 }
 
-void hash_iterate_deinit(struct hash_iterate_context *ctx)
+void hash_iterate_deinit(struct hash_iterate_context **_ctx)
 {
+	struct hash_iterate_context *ctx = *_ctx;
+
+	*_ctx = NULL;
 	hash_thaw(ctx->table);
 	i_free(ctx);
 }
@@ -463,7 +466,7 @@
 	iter = hash_iterate_init(src);
 	while (hash_iterate(iter, &key, &value))
 		hash_insert(dest, key, value);
-	hash_iterate_deinit(iter);
+	hash_iterate_deinit(&iter);
 
 	hash_thaw(dest);
 }
--- a/src/lib/hash.h	Sun Sep 16 12:31:27 2007 +0300
+++ b/src/lib/hash.h	Sun Sep 16 12:35:01 2007 +0300
@@ -15,8 +15,7 @@
 struct hash_table *
 hash_create(pool_t table_pool, pool_t node_pool, unsigned int initial_size,
 	    hash_callback_t *hash_cb, hash_cmp_callback_t *key_compare_cb);
-void _hash_destroy(struct hash_table **table);
-#define hash_destroy(table) _hash_destroy(&(table))
+void hash_destroy(struct hash_table **table);
 /* Remove all nodes from hash table. If free_collisions is TRUE, the
    memory allocated from node_pool is freed, or discarded with
    alloconly pools. */
@@ -40,7 +39,7 @@
 struct hash_iterate_context *hash_iterate_init(struct hash_table *table);
 bool hash_iterate(struct hash_iterate_context *ctx,
 		  void **key_r, void **value_r);
-void hash_iterate_deinit(struct hash_iterate_context *ctx);
+void hash_iterate_deinit(struct hash_iterate_context **ctx);
 
 /* Hash table isn't resized, and removed nodes aren't removed from
    the list while hash table is freezed. Supports nesting. */
--- a/src/login-common/login-proxy.c	Sun Sep 16 12:31:27 2007 +0300
+++ b/src/login-common/login-proxy.c	Sun Sep 16 12:35:01 2007 +0300
@@ -285,6 +285,6 @@
 	iter = hash_iterate_init(login_proxies);
 	while (hash_iterate(iter, &key, &value))
 		login_proxy_free(value);
-	hash_iterate_deinit(iter);
-	hash_destroy(login_proxies);
+	hash_iterate_deinit(&iter);
+	hash_destroy(&login_proxies);
 }
--- a/src/login-common/master.c	Sun Sep 16 12:31:27 2007 +0300
+++ b/src/login-common/master.c	Sun Sep 16 12:35:01 2007 +0300
@@ -265,7 +265,7 @@
 
 void master_deinit(void)
 {
-	hash_destroy(master_requests);
+	hash_destroy(&master_requests);
 
 	if (io_master != NULL)
 		io_remove(&io_master);
--- a/src/login-common/ssl-proxy-openssl.c	Sun Sep 16 12:31:27 2007 +0300
+++ b/src/login-common/ssl-proxy-openssl.c	Sun Sep 16 12:35:01 2007 +0300
@@ -793,8 +793,8 @@
 	iter = hash_iterate_init(ssl_proxies);
 	while (hash_iterate(iter, &key, &value))
 		ssl_proxy_destroy(value);
-	hash_iterate_deinit(iter);
-	hash_destroy(ssl_proxies);
+	hash_iterate_deinit(&iter);
+	hash_destroy(&ssl_proxies);
 
 	ssl_free_parameters(&ssl_params);
 	SSL_CTX_free(ssl_ctx);
--- a/src/master/auth-process.c	Sun Sep 16 12:31:27 2007 +0300
+++ b/src/master/auth-process.c	Sun Sep 16 12:35:01 2007 +0300
@@ -363,8 +363,8 @@
 	iter = hash_iterate_init(p->requests);
 	while (hash_iterate(iter, &key, &value))
 		auth_master_callback(NULL, NULL, value);
-	hash_iterate_deinit(iter);
-	hash_destroy(p->requests);
+	hash_iterate_deinit(&iter);
+	hash_destroy(&p->requests);
 
 	i_stream_destroy(&p->input);
 	o_stream_destroy(&p->output);
--- a/src/master/child-process.c	Sun Sep 16 12:31:27 2007 +0300
+++ b/src/master/child-process.c	Sun Sep 16 12:35:01 2007 +0300
@@ -182,5 +182,5 @@
 	/* make sure we log if child processes died unexpectedly */
 	sigchld_handler(SIGCHLD, NULL);
 	lib_signals_unset_handler(SIGCHLD, sigchld_handler, NULL);
-	hash_destroy(processes);
+	hash_destroy(&processes);
 }
--- a/src/master/login-process.c	Sun Sep 16 12:31:27 2007 +0300
+++ b/src/master/login-process.c	Sun Sep 16 12:35:01 2007 +0300
@@ -735,7 +735,7 @@
 		if (p->process.type == PROCESS_TYPE_LOGIN)
 			login_process_destroy(p);
 	}
-	hash_iterate_deinit(iter);
+	hash_iterate_deinit(&iter);
 
 	while (login_groups != NULL) {
 		struct login_group *group = login_groups;
@@ -760,7 +760,7 @@
 		if (p->process.type == PROCESS_TYPE_LOGIN && p->group == group)
 			(void)o_stream_send(p->output, &reply, sizeof(reply));
 	}
-	hash_iterate_deinit(iter);
+	hash_iterate_deinit(&iter);
 }
 
 static int login_group_start_missings(struct login_group *group)
--- a/src/master/mail-process.c	Sun Sep 16 12:31:27 2007 +0300
+++ b/src/master/mail-process.c	Sun Sep 16 12:35:01 2007 +0300
@@ -881,7 +881,7 @@
 		struct mail_process_group *group = value;
 		mail_process_group_free(group);
 	}
-	hash_iterate_deinit(iter);
+	hash_iterate_deinit(&iter);
 
-	hash_destroy(mail_process_groups);
+	hash_destroy(&mail_process_groups);
 }
--- a/src/plugins/acl/acl-cache.c	Sun Sep 16 12:31:27 2007 +0300
+++ b/src/plugins/acl/acl-cache.c	Sun Sep 16 12:35:01 2007 +0300
@@ -63,8 +63,8 @@
 
 	*_cache = NULL;
 	array_free(&cache->right_idx_name_map);
-	hash_destroy(cache->right_name_idx_map);
-	hash_destroy(cache->objects);
+	hash_destroy(&cache->right_name_idx_map);
+	hash_destroy(&cache->objects);
 	pool_unref(cache->right_names_pool);
 	i_free(cache);
 }
@@ -167,7 +167,7 @@
 
 		acl_cache_free_object_cache(obj_cache);
 	}
-	hash_iterate_deinit(iter);
+	hash_iterate_deinit(&iter);
 
 	hash_clear(cache->objects, FALSE);
 }
--- a/src/pop3-login/client.c	Sun Sep 16 12:31:27 2007 +0300
+++ b/src/pop3-login/client.c	Sun Sep 16 12:35:01 2007 +0300
@@ -257,7 +257,7 @@
 			}
 		}
 	}
-	hash_iterate_deinit(iter);
+	hash_iterate_deinit(&iter);
 
 	/* then kill them */
 	for (i = 0; i < destroy_count; i++) {
@@ -475,7 +475,7 @@
 
 		client_check_idle(client);
 	}
-	hash_iterate_deinit(iter);
+	hash_iterate_deinit(&iter);
 }
 
 unsigned int clients_get_count(void)
@@ -497,7 +497,7 @@
 			client_auth_ready(client);
 		}
 	}
-	hash_iterate_deinit(iter);
+	hash_iterate_deinit(&iter);
 }
 
 void clients_destroy_all(void)
@@ -511,7 +511,7 @@
 
 		client_destroy(client, "Disconnected: Shutting down");
 	}
-	hash_iterate_deinit(iter);
+	hash_iterate_deinit(&iter);
 }
 
 void clients_init(void)
@@ -522,7 +522,7 @@
 void clients_deinit(void)
 {
 	clients_destroy_all();
-	hash_destroy(clients);
+	hash_destroy(&clients);
 
 	i_assert(to_idle == NULL);
 }