add isl_hash_table_alloc and isl_hash_table_free
authorSven Verdoolaege <skimo@kotnet.org>
Fri, 6 Mar 2009 17:26:34 +0000 (18:26 +0100)
committerSven Verdoolaege <skimo@kotnet.org>
Fri, 20 Mar 2009 14:21:03 +0000 (15:21 +0100)
include/isl_hash.h
isl_hash.c

index a4d85ba..c596b5e 100644 (file)
@@ -41,6 +41,9 @@ struct isl_hash_table {
 
 struct isl_ctx;
 
+struct isl_hash_table *isl_hash_table_alloc(struct isl_ctx *ctx, int min_size);
+void isl_hash_table_free(struct isl_ctx *ctx, struct isl_hash_table *table);
+
 int isl_hash_table_init(struct isl_ctx *ctx, struct isl_hash_table *table,
                        int min_size);
 void isl_hash_table_clear(struct isl_hash_table *table);
index 6c4ed42..f751f46 100644 (file)
@@ -42,6 +42,19 @@ int isl_hash_table_init(struct isl_ctx *ctx, struct isl_hash_table *table,
        return 0;
 }
 
+struct isl_hash_table *isl_hash_table_alloc(struct isl_ctx *ctx, int min_size)
+{
+       struct isl_hash_table *table = NULL;
+
+       table = isl_alloc_type(ctx, struct isl_hash_table);
+       if (isl_hash_table_init(ctx, table, min_size))
+               goto error;
+       return table;
+error:
+       isl_hash_table_free(ctx, table);
+       return NULL;
+}
+
 void isl_hash_table_clear(struct isl_hash_table *table)
 {
        if (!table)
@@ -49,6 +62,14 @@ void isl_hash_table_clear(struct isl_hash_table *table)
        free(table->entries);
 }
 
+void isl_hash_table_free(struct isl_ctx *ctx, struct isl_hash_table *table)
+{
+       if (!table)
+               return;
+       isl_hash_table_clear(table);
+       free(table);
+}
+
 struct isl_hash_table_entry *isl_hash_table_find(struct isl_ctx *ctx,
                                struct isl_hash_table *table,
                                uint32_t key_hash,