X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=isl_ctx.c;h=6f02684db1e90f991b07f7489d1c23a6b89ab8a2;hb=de51a9bc4da5dd3f1f9f57c2362da6f9752c44e0;hp=bea6efb9d02f924bc8ce7ec0338813b5978c7076;hpb=f5e4e6f324ebd2eb8edb47e57880be621a3e58e1;p=platform%2Fupstream%2Fisl.git diff --git a/isl_ctx.c b/isl_ctx.c index bea6efb..6f02684 100644 --- a/isl_ctx.c +++ b/isl_ctx.c @@ -1,7 +1,7 @@ /* * Copyright 2008-2009 Katholieke Universiteit Leuven * - * Use of this software is governed by the GNU LGPLv2.1 license + * Use of this software is governed by the MIT license * * Written by Sven Verdoolaege, K.U.Leuven, Departement * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium @@ -9,7 +9,28 @@ #include #include -#include +#include + +void isl_handle_error(isl_ctx *ctx, enum isl_error error, const char *msg, + const char *file, int line) +{ + if (!ctx) + return; + + isl_ctx_set_error(ctx, error); + + switch (ctx->opt->on_error) { + case ISL_ON_ERROR_WARN: + fprintf(stderr, "%s:%d: %s\n", file, line, msg); + return; + case ISL_ON_ERROR_CONTINUE: + return; + case ISL_ON_ERROR_ABORT: + fprintf(stderr, "%s:%d: %s\n", file, line, msg); + abort(); + return; + } +} static struct isl_options *find_nested_options(struct isl_args *args, void *opt, struct isl_args *wanted) @@ -43,6 +64,8 @@ void *isl_ctx_peek_options(isl_ctx *ctx, struct isl_args *args) { if (!ctx) return NULL; + if (args == &isl_options_args) + return ctx->opt; return find_nested_options(ctx->user_args, ctx->user_opt, args); } @@ -132,7 +155,11 @@ void isl_ctx_free(struct isl_ctx *ctx) { if (!ctx) return; - isl_assert(ctx, ctx->ref == 0, return); + if (ctx->ref != 0) + isl_die(ctx, isl_error_invalid, + "isl_ctx freed, but some objects still reference it", + return); + isl_hash_table_clear(&ctx->id_table); isl_blk_clear_cache(ctx); isl_int_clear(ctx->zero); @@ -142,7 +169,7 @@ void isl_ctx_free(struct isl_ctx *ctx) isl_int_clear(ctx->normalize_gcd); isl_args_free(ctx->user_args, ctx->user_opt); if (ctx->opt_allocated) - free(ctx->opt); + isl_options_free(ctx->opt); free(ctx->stats); free(ctx); }