From: Mythri Alle Date: Sun, 8 Jul 2012 14:27:01 +0000 (+0200) Subject: isl_hash.c: reset the number of entries to 0 when growing the hash table X-Git-Tag: isl-0.11~223^2~13 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cb3a5623eb615fc73b74dfa271795651ed340044;p=platform%2Fupstream%2Fisl.git isl_hash.c: reset the number of entries to 0 when growing the hash table The hash table is grown by creating a new table and adding the entries of the old table to the new table. Since the new table starts out as being empty, the number of entries should be reset to 0. Not only would the old code result in isl_union_map_n_map returing the wrong value if the underlying hash table had ever been grown, it would also result in the table subsequently being grown again far too early. Signed-off-by: Mythri Alle Signed-off-by: Sven Verdoolaege --- diff --git a/isl_hash.c b/isl_hash.c index c997402..0ce66bf 100644 --- a/isl_hash.c +++ b/isl_hash.c @@ -64,6 +64,7 @@ int isl_hash_table_init(struct isl_ctx *ctx, struct isl_hash_table *table, static int grow_table(struct isl_ctx *ctx, struct isl_hash_table *table, int (*eq)(const void *entry, const void *val)) { + int n; size_t old_size, size; struct isl_hash_table_entry *entries; uint32_t h; @@ -78,6 +79,8 @@ static int grow_table(struct isl_ctx *ctx, struct isl_hash_table *table, return -1; } + n = table->n; + table->n = 0; table->bits++; for (h = 0; h < old_size; ++h) { @@ -92,6 +95,7 @@ static int grow_table(struct isl_ctx *ctx, struct isl_hash_table *table, table->bits--; free(table->entries); table->entries = entries; + table->n = n; return -1; }