isl_hash_table_foreach: add user argument
authorSven Verdoolaege <skimo@kotnet.org>
Sun, 25 Jul 2010 09:34:55 +0000 (11:34 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Fri, 30 Jul 2010 19:57:01 +0000 (21:57 +0200)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
include/isl_hash.h
isl_hash.c
isl_stream.c

index 66c6c79..97e008b 100644 (file)
@@ -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);
index 4f7e492..5abf9fd 100644 (file)
@@ -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;
index 7ddc75a..7e70a6e 100644 (file)
@@ -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);