MCPcopy Create free account
hub / github.com/apache/madlib / SN_create_env

Function SN_create_env

src/libstemmer/runtime/api.c:5–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3#include "header.h"
4
5extern struct SN_env * SN_create_env(int S_size, int I_size, int B_size)
6{
7 struct SN_env * z = (struct SN_env *) calloc(1, sizeof(struct SN_env));
8 if (z == NULL) return NULL;
9 z->p = create_s();
10 if (z->p == NULL) goto error;
11 if (S_size)
12 {
13 int i;
14 z->S = (symbol * *) calloc(S_size, sizeof(symbol *));
15 if (z->S == NULL) goto error;
16
17 for (i = 0; i < S_size; i++)
18 {
19 z->S[i] = create_s();
20 if (z->S[i] == NULL) goto error;
21 }
22 }
23
24 if (I_size)
25 {
26 z->I = (int *) calloc(I_size, sizeof(int));
27 if (z->I == NULL) goto error;
28 }
29
30 if (B_size)
31 {
32 z->B = (unsigned char *) calloc(B_size, sizeof(unsigned char));
33 if (z->B == NULL) goto error;
34 }
35
36 return z;
37error:
38 SN_close_env(z, S_size);
39 return NULL;
40}
41
42extern void SN_close_env(struct SN_env * z, int S_size)
43{

Calls 2

create_sFunction · 0.85
SN_close_envFunction · 0.85

Tested by

no test coverage detected