X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=name.c;h=3f44b12a39919408ddc0e247e8d7b9760b41dfe3;hb=7336a58b86f85500a6b0ad70ebb06c9750094053;hp=41ca2ec80a595f363bfc64ccbd3bef7b046da9fd;hpb=d74df18bfc19daa897225522e9c5d89b2be849ee;p=chise%2Fconcord.git diff --git a/name.c b/name.c index 41ca2ec..3f44b12 100644 --- a/name.c +++ b/name.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003,2004,2005,2006 MORIOKA Tomohiko +/* Copyright (C) 2003, 2004, 2005, 2006, 2013 MORIOKA Tomohiko This file is part of the CONCORD Library. The CONCORD Library is free software; you can redistribute it and/or @@ -19,22 +19,7 @@ #include #include #include "concord-name.h" - -struct CONCORD_HASH_TABLE_ENTRY -{ - void *key; - void *value; -}; - -struct CONCORD_HASH_TABLE -{ - size_t size; - CONCORD_HASH_TABLE_ENTRY *data; -}; - -CONCORD_HASH_TABLE* concord_make_hash_table (size_t size); -void concord_destroy_hash_table (CONCORD_HASH_TABLE* hash); -int concord_hash_c_string (const unsigned char *ptr); +#include "hash-i.h" CONCORD_HASH_TABLE* concord_make_hash_table (size_t size) @@ -70,14 +55,14 @@ concord_destroy_hash_table (CONCORD_HASH_TABLE* table) /* derived from hashpjw, Dragon Book P436. */ -int +unsigned long concord_hash_c_string (const unsigned char *ptr) { - int hash = 0; + unsigned long hash = 0; while (*ptr != '\0') { - int g; + unsigned long g; hash = (hash << 4) + *ptr++; g = hash & 0xf0000000; if (g) @@ -194,6 +179,7 @@ concord_name_table_grow (CONCORD_NAME_TABLE* table) } } } + free (table->data); table->size = new_table->size; table->data = new_table->data; free (new_table);