From 399b9bcaf2199202853e55acb58b7a5b3632aeec Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sun, 25 Jul 2010 11:34:55 +0200 Subject: [PATCH] isl_hash_table_foreach: add user argument Signed-off-by: Sven Verdoolaege --- include/isl_hash.h | 2 +- isl_hash.c | 5 +++-- isl_stream.c | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/isl_hash.h b/include/isl_hash.h index 66c6c79f..97e008b0 100644 --- a/include/isl_hash.h +++ b/include/isl_hash.h @@ -67,7 +67,7 @@ struct isl_hash_table_entry *isl_hash_table_find(struct isl_ctx *ctx, const void *val, int reserve); int isl_hash_table_foreach(struct isl_ctx *ctx, struct isl_hash_table *table, - int (*fn)(void *entry)); + int (*fn)(void *entry, void *user), void *user); void isl_hash_table_remove(struct isl_ctx *ctx, struct isl_hash_table *table, struct isl_hash_table_entry *entry); diff --git a/isl_hash.c b/isl_hash.c index 4f7e4926..5abf9fd1 100644 --- a/isl_hash.c +++ b/isl_hash.c @@ -163,14 +163,15 @@ struct isl_hash_table_entry *isl_hash_table_find(struct isl_ctx *ctx, int isl_hash_table_foreach(struct isl_ctx *ctx, struct isl_hash_table *table, - int (*fn)(void *entry)) + int (*fn)(void *entry, void *user), void *user) { size_t size; uint32_t h; size = 1 << table->bits; for (h = 0; h < size; ++ h) - if (table->entries[h].data && fn(table->entries[h].data) < 0) + if (table->entries[h].data && + fn(table->entries[h].data, user) < 0) return -1; return 0; diff --git a/isl_stream.c b/isl_stream.c index 7ddc75a0..7e70a6e2 100644 --- a/isl_stream.c +++ b/isl_stream.c @@ -538,7 +538,7 @@ int isl_stream_is_empty(struct isl_stream *s) return 0; } -static int free_keyword(void *p) +static int free_keyword(void *p, void *user) { struct isl_keyword *keyword = p; @@ -570,7 +570,7 @@ void isl_stream_free(struct isl_stream *s) isl_token_free(tok); } if (s->keywords) { - isl_hash_table_foreach(s->ctx, s->keywords, free_keyword); + isl_hash_table_foreach(s->ctx, s->keywords, &free_keyword, NULL); isl_hash_table_free(s->ctx, s->keywords); } isl_ctx_deref(s->ctx); -- 2.11.4.GIT