X-Git-Url: http://git.chise.org/gitweb/?p=chise%2Fconcord.git;a=blobdiff_plain;f=name.c;h=8155dec8017a32ccf02866e93fe477a45f76aea8;hp=517c6b227d02379c6cfcbcf8773909224b612d49;hb=07198aca24598d8b958892844a59de44701493a1;hpb=d0643a1a7a29058771d020e4b24f2833fdce9522 diff --git a/name.c b/name.c index 517c6b2..8155dec 100644 --- a/name.c +++ b/name.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003,2004,2005 MORIOKA Tomohiko +/* Copyright (C) 2003,2004,2005,2006 MORIOKA Tomohiko This file is part of the CONCORD Library. The CONCORD Library is free software; you can redistribute it and/or @@ -34,7 +34,7 @@ struct CONCORD_HASH_TABLE 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); +unsigned long concord_hash_c_string (const unsigned char *ptr); CONCORD_HASH_TABLE* concord_make_hash_table (size_t size) @@ -70,14 +70,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) @@ -114,7 +114,7 @@ concord_destroy_name_table (CONCORD_NAME_TABLE* table) int concord_name_table_put (CONCORD_NAME_TABLE* table, - const unsigned char *key, void *value) + const char *key, void *value) { int i, index; CONCORD_NAME_TABLE_ENTRY* entry; @@ -122,7 +122,7 @@ concord_name_table_put (CONCORD_NAME_TABLE* table, if (table == NULL) return -1; - index = concord_hash_c_string (key) % table->size; + index = concord_hash_c_string ((unsigned char*)key) % table->size; for (i = index; i < table->size; i++) { entry = &table->data[i]; @@ -149,8 +149,7 @@ concord_name_table_put (CONCORD_NAME_TABLE* table, } void * -concord_name_table_get (CONCORD_NAME_TABLE* table, - const unsigned char *key) +concord_name_table_get (CONCORD_NAME_TABLE* table, const char *key) { int i, index; CONCORD_NAME_TABLE_ENTRY entry; @@ -158,7 +157,7 @@ concord_name_table_get (CONCORD_NAME_TABLE* table, if (table == NULL) return NULL; - index = concord_hash_c_string (key) % table->size; + index = concord_hash_c_string ((unsigned char*)key) % table->size; for (i = index; i < table->size; i++) { entry = table->data[i];