Coverage Report

Created: 2025-11-02 06:51

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/tinysparql/subprojects/libstemmer_c-3.0.1/runtime/api.c
Line
Count
Source
1
2
#include <stdlib.h> /* for malloc, calloc, free */
3
#include "header.h"
4
5
extern struct SN_env * SN_create_env(int S_size, int I_size)
6
0
{
7
0
    static const struct SN_env default_SN_env = {};
8
0
    struct SN_env * z = (struct SN_env *) malloc(sizeof(struct SN_env));
9
0
    if (z == NULL) return NULL;
10
0
    *z = default_SN_env;
11
0
    z->p = create_s();
12
0
    if (z->p == NULL) goto error;
13
0
    if (S_size)
14
0
    {
15
0
        int i;
16
0
        z->S = (symbol * *) malloc(S_size * sizeof(symbol *));
17
0
        if (z->S == NULL) goto error;
18
19
0
        for (i = 0; i < S_size; i++)
20
0
        {
21
0
            z->S[i] = create_s();
22
0
            if (z->S[i] == NULL) {
23
0
                S_size = i;
24
0
                goto error;
25
0
            }
26
0
        }
27
0
    }
28
29
0
    if (I_size)
30
0
    {
31
0
        z->I = (int *) calloc(I_size, sizeof(int));
32
0
        if (z->I == NULL) goto error;
33
0
    }
34
35
0
    return z;
36
0
error:
37
0
    SN_close_env(z, S_size);
38
0
    return NULL;
39
0
}
40
41
extern void SN_close_env(struct SN_env * z, int S_size)
42
0
{
43
0
    if (z == NULL) return;
44
0
    if (z->S)
45
0
    {
46
0
        int i;
47
0
        for (i = 0; i < S_size; i++)
48
0
        {
49
0
            lose_s(z->S[i]);
50
0
        }
51
0
        free(z->S);
52
0
    }
53
0
    free(z->I);
54
0
    if (z->p) lose_s(z->p);
55
0
    free(z);
56
0
}
57
58
extern int SN_set_current(struct SN_env * z, int size, const symbol * s)
59
0
{
60
    int err = replace_s(z, 0, z->l, size, s, NULL);
61
0
    z->c = 0;
62
0
    return err;
63
0
}