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