X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=isl_id.c;h=410218df72d8c442f74fcc21fced90843b6106ff;hb=63fb8a7f484648c3caa25351c8c94ac2395ec563;hp=fd3f68d1e65a93d1c696ede7c01090ecaa026059;hpb=056289f285e62c52cc59ee826172e4d3092ef3fe;p=platform%2Fupstream%2Fisl.git diff --git a/isl_id.c b/isl_id.c index fd3f68d..410218d 100644 --- a/isl_id.c +++ b/isl_id.c @@ -11,6 +11,11 @@ #include #include +#undef BASE +#define BASE id + +#include + /* A special, static isl_id to use as domains (and ranges) * of sets and parameters domains. * The user should never get a hold on this isl_id. @@ -44,7 +49,7 @@ static __isl_give isl_id *id_alloc(isl_ctx *ctx, const char *name, void *user) if (name && !copy) return NULL; - id = isl_alloc_type(ctx, struct isl_id); + id = isl_calloc_type(ctx, struct isl_id); if (!id) goto error; @@ -135,6 +140,19 @@ uint32_t isl_hash_id(uint32_t hash, __isl_keep isl_id *id) return hash; } +/* Replace the free_user callback by "free_user". + */ +__isl_give isl_id *isl_id_set_free_user(__isl_take isl_id *id, + __isl_give void (*free_user)(void *user)) +{ + if (!id) + return NULL; + + id->free_user = free_user; + + return id; +} + /* If the id has a negative refcount, then it is a static isl_id * and should not be freed. */ @@ -159,6 +177,9 @@ void *isl_id_free(__isl_take isl_id *id) else isl_hash_table_remove(id->ctx, &id->ctx->id_table, entry); + if (id->free_user) + id->free_user(id->user); + free((char *)id->name); isl_ctx_deref(id->ctx); free(id);