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