Line data Source code
1 : #include "snowball_runtime.h"
2 :
3 : static const struct SN_env default_SN_env;
4 :
5 22 : extern struct SN_env * SN_new_env(int alloc_size)
6 : {
7 22 : struct SN_env * z = (struct SN_env *) malloc(alloc_size);
8 22 : if (z == NULL) return NULL;
9 22 : *z = default_SN_env;
10 22 : z->p = create_s();
11 22 : if (z->p == NULL) {
12 0 : SN_delete_env(z);
13 0 : return NULL;
14 : }
15 22 : return z;
16 : }
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 : }
24 :
25 3425 : extern int SN_set_current(struct SN_env * z, int size, const symbol * s)
26 : {
27 3425 : int err = replace_s(z, 0, z->l, size, s);
28 3425 : z->c = 0;
29 3425 : return err;
30 : }
|