PostgreSQL Source Code git master
api.c
Go to the documentation of this file.
1#include "snowball_runtime.h"
2
3static const struct SN_env default_SN_env;
4
5extern struct SN_env * SN_new_env(int alloc_size)
6{
7 struct SN_env * z = (struct SN_env *) malloc(alloc_size);
8 if (z == NULL) return NULL;
10 z->p = create_s();
11 if (z->p == NULL) {
13 return NULL;
14 }
15 return z;
16}
17
18extern void SN_delete_env(struct SN_env * z)
19{
20 if (z == NULL) return;
21 if (z->p) lose_s(z->p);
22 free(z);
23}
24
25extern int SN_set_current(struct SN_env * z, int size, const symbol * s)
26{
27 int err = replace_s(z, 0, z->l, size, s);
28 z->c = 0;
29 return err;
30}
int SN_set_current(struct SN_env *z, int size, const symbol *s)
Definition: api.c:25
static const struct SN_env default_SN_env
Definition: api.c:3
void SN_delete_env(struct SN_env *z)
Definition: api.c:18
struct SN_env * SN_new_env(int alloc_size)
Definition: api.c:5
unsigned char symbol
Definition: api.h:4
void err(int eval, const char *fmt,...)
Definition: err.c:43
#define free(a)
#define malloc(a)
Definition: api.h:15
symbol * p
Definition: api.h:16
int c
Definition: api.h:17
int l
Definition: api.h:17
SNOWBALL_ERR replace_s(struct SN_env *z, int c_bra, int c_ket, int s_size, const symbol *s)
Definition: utilities.c:389
void lose_s(symbol *p)
Definition: utilities.c:31
symbol * create_s(void)
Definition: utilities.c:20