static __isl_give isl_id *id_alloc(isl_ctx *ctx, const char *name, void *user) { const char *copy = name ? strdup(name) : NULL; isl_id *id; if (name && !copy) return NULL; id = isl_alloc_type(ctx, struct isl_id); if (!id) goto error; id->ctx = ctx; isl_ctx_ref(id->ctx); id->ref = 1; id->name = copy; id->user = user; id->hash = isl_hash_init(); if (name) id->hash = isl_hash_string(id->hash, name); else id->hash = isl_hash_builtin(id->hash, user); return id; error: free((char *)copy); return NULL; }
static struct isl_stream* isl_stream_new(struct isl_ctx *ctx) { int i; struct isl_stream *s = isl_alloc_type(ctx, struct isl_stream); if (!s) return NULL; s->ctx = ctx; isl_ctx_ref(s->ctx); s->file = NULL; s->str = NULL; s->len = 0; s->line = 1; s->col = 0; s->eof = 0; s->c = -1; s->n_un = 0; for (i = 0; i < 5; ++i) s->tokens[i] = NULL; s->n_token = 0; s->keywords = NULL; s->size = 256; s->buffer = isl_alloc_array(ctx, char, s->size); if (!s->buffer) goto error; return s; error: isl_stream_free(s); return NULL; }
__isl_give isl_space *isl_space_alloc(isl_ctx *ctx, unsigned nparam, unsigned n_in, unsigned n_out) { isl_space *dim; dim = isl_alloc_type(ctx, struct isl_space); if (!dim) return NULL; dim->ctx = ctx; isl_ctx_ref(ctx); dim->ref = 1; dim->nparam = nparam; dim->n_in = n_in; dim->n_out = n_out; dim->tuple_id[0] = NULL; dim->tuple_id[1] = NULL; dim->nested[0] = NULL; dim->nested[1] = NULL; dim->n_id = 0; dim->ids = NULL; return dim; }