X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fhash.c;h=bcf5244f049ca64be73130476386a7e95e6cf586;hb=d7b5d9144738a5a8989d45a01f4e458a78b68c0b;hp=1d9c2f5b3424188e622a79eb861c702ebda859e5;hpb=9e41822d23f3c62349751e172a946e832c4a96eb;p=pspp diff --git a/src/hash.c b/src/hash.c index 1d9c2f5b34..bcf5244f04 100644 --- a/src/hash.c +++ b/src/hash.c @@ -20,15 +20,19 @@ #include #include "hash.h" #include "error.h" +#include #include #include #include #include "algorithm.h" #include "alloc.h" -#include "bool.h" +#include #include "misc.h" #include "str.h" +#include "gettext.h" +#define _(msgid) gettext (msgid) + /* Note for constructing hash functions: You can store the hash values in the records, then compare hash @@ -73,7 +77,7 @@ next_power_of_2 (size_t x) unsigned hsh_hash_bytes (const void *buf_, size_t size) { - const unsigned char *buf = buf_; + const unsigned char *buf = (const unsigned char *) buf_; unsigned hash; assert (buf != NULL); @@ -89,7 +93,7 @@ hsh_hash_bytes (const void *buf_, size_t size) unsigned hsh_hash_string (const char *s_) { - const unsigned char *s = s_; + const unsigned char *s = (const unsigned char *) s_; unsigned hash; assert (s != NULL); @@ -105,7 +109,7 @@ hsh_hash_string (const char *s_) unsigned hsh_hash_case_string (const char *s_) { - const unsigned char *s = s_; + const unsigned char *s = (const unsigned char *) s_; unsigned hash; assert (s != NULL); @@ -174,7 +178,7 @@ hsh_create (int size, hsh_compare_func *compare, hsh_hash_func *hash, if (size < 4) size = 4; h->size = next_power_of_2 (size); - h->entries = xmalloc (sizeof *h->entries * h->size); + h->entries = xnmalloc (h->size, sizeof *h->entries); for (i = 0; i < h->size; i++) h->entries[i] = NULL; h->aux = aux; @@ -264,7 +268,7 @@ rehash (struct hsh_table *h, size_t new_size) end = begin + h->size; h->size = new_size; - h->entries = xmalloc (sizeof *h->entries * h->size); + h->entries = xnmalloc (h->size, sizeof *h->entries); for (i = 0; i < h->size; i++) h->entries[i] = NULL; for (table_p = begin; table_p < end; table_p++) @@ -381,7 +385,7 @@ hsh_data_copy (struct hsh_table *h) void **copy; assert (h != NULL); - copy = xmalloc ((h->used + 1) * sizeof *copy); + copy = xnmalloc ((h->used + 1), sizeof *copy); copy_if (h->entries, h->size, sizeof *h->entries, copy, not_null, NULL); copy[h->used] = NULL; return copy;