isl_basic_map_dup: copy flags of original to duplicate
[isl.git] / isl_ctx.c
bloba556c6e9a48bee010d258b144a0f882c6268350c
1 #include "isl_ctx.h"
2 #include "isl_vec.h"
3 #ifdef ISL_POLYLIB
4 #include <polylib/polylibgmp.h>
5 #endif
7 struct isl_ctx *isl_ctx_alloc()
9 struct isl_ctx *ctx = NULL;
11 ctx = isl_alloc_type(NULL, struct isl_ctx);
12 if (!ctx)
13 goto error;
15 if (isl_hash_table_init(ctx, &ctx->name_hash, 0))
16 goto error;
18 ctx->ref = 0;
20 isl_int_init(ctx->one);
21 isl_int_set_si(ctx->one, 1);
23 ctx->n_cached = 0;
25 #ifdef ISL_POLYLIB
26 ctx->MaxRays = POL_NO_DUAL | POL_INTEGER;
27 #endif
29 ctx->lp_solver = ISL_LP_TAB;
31 return ctx;
32 error:
33 free(ctx);
34 return NULL;
37 void isl_ctx_ref(struct isl_ctx *ctx)
39 ctx->ref++;
42 void isl_ctx_deref(struct isl_ctx *ctx)
44 isl_assert(ctx, ctx->ref > 0, return);
45 ctx->ref--;
48 void isl_ctx_free(struct isl_ctx *ctx)
50 if (!ctx)
51 return;
52 isl_assert(ctx, ctx->ref == 0, return);
53 isl_hash_table_clear(&ctx->name_hash);
54 isl_blk_clear_cache(ctx);
55 isl_int_clear(ctx->one);
56 free(ctx);