Branch data Line data Source code
1 : : #include "snowball_runtime.h"
2 : :
3 : : static const struct SN_env default_SN_env;
4 : :
5 : 6 : extern struct SN_env * SN_new_env(int alloc_size)
6 : : {
7 : 6 : struct SN_env * z = (struct SN_env *) malloc(alloc_size);
8 [ + - ]: 6 : if (z == NULL) return NULL;
9 : 6 : *z = default_SN_env;
10 : 6 : z->p = create_s();
11 [ + - ]: 6 : if (z->p == NULL) {
12 : 0 : SN_delete_env(z);
13 : 0 : return NULL;
14 : : }
15 : 6 : return z;
16 : 6 : }
17 : :
18 : 0 : extern void SN_delete_env(struct SN_env * z)
19 : : {
20 [ # # ]: 0 : if (z == NULL) return;
21 [ # # ]: 0 : if (z->p) lose_s(z->p);
22 : 0 : free(z);
23 : 0 : }
24 : :
25 : 1127 : extern int SN_set_current(struct SN_env * z, int size, const symbol * s)
26 : : {
27 : 1127 : int err = replace_s(z, 0, z->l, size, s);
28 : 1127 : z->c = 0;
29 : 2254 : return err;
30 : 1127 : }
|