From 9ead2399548621f96dfd450f9d7c09bef9332cf6 Mon Sep 17 00:00:00 2001 From: tomo Date: Mon, 1 Mar 2004 01:45:25 +0000 Subject: [PATCH] (chise_make_name_table): Change initial number of hash table to 256. (chise_destroy_name_table): Destroy each entry. --- name.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/name.c b/name.c index 62dff32..b7b3026 100644 --- a/name.c +++ b/name.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MORIOKA Tomohiko +/* Copyright (C) 2003,2004 MORIOKA Tomohiko This file is part of the CHISE Library. The CHISE Library is free software; you can redistribute it and/or @@ -60,12 +60,12 @@ chise_make_hash_table (size_t size) } void -chise_destroy_hash_table (CHISE_HASH_TABLE* hash) +chise_destroy_hash_table (CHISE_HASH_TABLE* table) { - if (hash == NULL) + if (table == NULL) return; - free (hash->data); - free (hash); + free (table->data); + free (table); } @@ -90,12 +90,25 @@ chise_hash_c_string (const unsigned char *ptr) CHISE_NAME_TABLE* chise_make_name_table () { - return chise_make_hash_table (32); + return chise_make_hash_table (256); } void chise_destroy_name_table (CHISE_NAME_TABLE* table) { + int i; + + for (i = 0; i < table->size; i++) + { + CHISE_NAME_TABLE_ENTRY entry = table->data[i]; + + if (entry.key != NULL) + { + if (entry.value != NULL) + free (entry.value); + free (entry.key); + } + } chise_destroy_hash_table (table); } @@ -161,7 +174,8 @@ int chise_name_table_grow (CHISE_NAME_TABLE* table) { CHISE_NAME_TABLE *new_table - = chise_make_hash_table (table->size * 2); + = chise_make_hash_table ( table->size * 2 + /* - (table->size * 4 / 5) */ ); int i; if (new_table == NULL) -- 1.7.10.4