X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fhash.c;h=2544a75d0dcd025f82668bfc24a47dfaeb2ad70c;hb=f1696fab032a5ae5c44e3a3dedba343fce9ffd5c;hp=588b311b45774c37cc52d5476b4a79b24b589b17;hpb=7dbe58807d4243d99dc51d3797fdb8c81e87d0a4;p=pspp diff --git a/src/hash.c b/src/hash.c index 588b311b45..2544a75d0d 100644 --- a/src/hash.c +++ b/src/hash.c @@ -142,7 +142,9 @@ hsh_create (int size, hsh_compare_func *compare, hsh_hash_func *hash, struct hsh_table *h; int i; - assert (size > 0); + if ( size == 0 ) + return NULL; + assert (compare != NULL); assert (hash != NULL); @@ -175,6 +177,8 @@ hsh_clear (struct hsh_table *h) for (i = 0; i < h->size; i++) h->entries[i] = NULL; + + h->used = 0; } /* Destroys table H and all its contents. */ @@ -259,6 +263,9 @@ comparison_helper (const void *a_, const void *b_, void *h_) void *const *b = b_; struct hsh_table *h = h_; + assert(a); + assert(b); + return h->compare (*a, *b, h->aux); }