1#include <stdlib.h>
2#include "../include/cloog/cloog.h"
3
4/**
5 * Allocate state and initialize backend independent part.
6 */
7CloogState *cloog_core_state_malloc(void)
8{
9  CloogState *state;
10
11  state = (CloogState *)malloc(sizeof(CloogState));
12  if (!state)
13    cloog_die("memory overflow.\n");
14
15  state->backend = NULL;
16
17  cloog_int_init(state->zero);
18  cloog_int_set_si(state->zero, 0);
19  cloog_int_init(state->one);
20  cloog_int_set_si(state->one, 1);
21  cloog_int_init(state->negone);
22  cloog_int_set_si(state->negone, -1);
23
24  state->block_allocated = 0;
25  state->block_freed = 0;
26  state->block_max = 0;
27
28  state->domain_allocated = 0;
29  state->domain_freed = 0;
30  state->domain_max = 0;
31
32  state->loop_allocated = 0;
33  state->loop_freed = 0;
34  state->loop_max = 0;
35
36  state->statement_allocated = 0;
37  state->statement_freed = 0;
38  state->statement_max = 0;
39
40  return state;
41}
42
43/**
44 * Free state.
45 */
46void cloog_core_state_free(CloogState *state)
47{
48  cloog_int_clear(state->zero);
49  cloog_int_clear(state->one);
50  cloog_int_clear(state->negone);
51  free(state);
52}
53