LCOV - code coverage report
Current view: top level - src/backend/snowball/libstemmer - api.c (source / functions) Hit Total Coverage
Test: PostgreSQL Lines: 17 34 50.0 %
Date: 2017-09-29 15:12:54 Functions: 2 3 66.7 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.11