PostgreSQL Source Code  git master
regc_cvec.c File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

static struct cvecnewcvec (int nchrs, int nranges)
 
static struct cvecclearcvec (struct cvec *cv)
 
static void addchr (struct cvec *cv, chr c)
 
static void addrange (struct cvec *cv, chr from, chr to)
 
static struct cvecgetcvec (struct vars *v, int nchrs, int nranges)
 
static void freecvec (struct cvec *cv)
 

Function Documentation

◆ addchr()

static void addchr ( struct cvec cv,
chr  c 
)
static

Definition at line 79 of file regc_cvec.c.

81 {
82  assert(cv->nchrs < cv->chrspace);
83  cv->chrs[cv->nchrs++] = c;
84 }
char * c
#define assert(x)
Definition: regcustom.h:56
int chrspace
Definition: regguts.h:281
int nchrs
Definition: regguts.h:280
chr * chrs
Definition: regguts.h:282

References assert, cvec::chrs, cvec::chrspace, and cvec::nchrs.

Referenced by allcases(), cclasscvec(), eclass(), and range().

◆ addrange()

static void addrange ( struct cvec cv,
chr  from,
chr  to 
)
static

Definition at line 90 of file regc_cvec.c.

93 {
94  assert(cv->nranges < cv->rangespace);
95  cv->ranges[cv->nranges * 2] = from;
96  cv->ranges[cv->nranges * 2 + 1] = to;
97  cv->nranges++;
98 }
int rangespace
Definition: regguts.h:284
chr * ranges
Definition: regguts.h:285
int nranges
Definition: regguts.h:283

References assert, cvec::nranges, cvec::ranges, and cvec::rangespace.

Referenced by bringetbitmap(), cclasscvec(), and range().

◆ clearcvec()

static struct cvec* clearcvec ( struct cvec cv)
static

Definition at line 66 of file regc_cvec.c.

67 {
68  assert(cv != NULL);
69  cv->nchrs = 0;
70  cv->nranges = 0;
71  cv->cclasscode = -1;
72  return cv;
73 }
int cclasscode
Definition: regguts.h:286

References assert, cvec::cclasscode, cvec::nchrs, and cvec::nranges.

Referenced by getcvec(), and newcvec().

◆ freecvec()

static void freecvec ( struct cvec cv)
static

Definition at line 135 of file regc_cvec.c.

136 {
137  FREE(cv);
138 }
#define FREE(ptr)
Definition: cryptohash.c:37

References FREE.

Referenced by getcvec().

◆ getcvec()

static struct cvec* getcvec ( struct vars v,
int  nchrs,
int  nranges 
)
static

Definition at line 112 of file regc_cvec.c.

115 {
116  /* recycle existing transient cvec if large enough */
117  if (v->cv != NULL && nchrs <= v->cv->chrspace &&
118  nranges <= v->cv->rangespace)
119  return clearcvec(v->cv);
120 
121  /* nope, make a new one */
122  if (v->cv != NULL)
123  freecvec(v->cv);
124  v->cv = newcvec(nchrs, nranges);
125  if (v->cv == NULL)
126  ERR(REG_ESPACE);
127 
128  return v->cv;
129 }
#define ERR
Definition: _int.h:161
static void freecvec(struct cvec *cv)
Definition: regc_cvec.c:135
static struct cvec * clearcvec(struct cvec *cv)
Definition: regc_cvec.c:66
static struct cvec * newcvec(int nchrs, int nranges)
Definition: regc_cvec.c:45
#define REG_ESPACE
Definition: regex.h:149
struct cvec * cv
Definition: regcomp.c:303

References cvec::chrspace, clearcvec(), vars::cv, ERR, freecvec(), cvec::nchrs, newcvec(), cvec::nranges, and REG_ESPACE.

Referenced by allcases(), cclasscvec(), eclass(), and range().

◆ newcvec()

static struct cvec* newcvec ( int  nchrs,
int  nranges 
)
static

Definition at line 45 of file regc_cvec.c.

47 {
48  size_t nc = (size_t) nchrs + (size_t) nranges * 2;
49  size_t n = sizeof(struct cvec) + nc * sizeof(chr);
50  struct cvec *cv = (struct cvec *) MALLOC(n);
51 
52  if (cv == NULL)
53  return NULL;
54  cv->chrspace = nchrs;
55  cv->chrs = (chr *) (((char *) cv) + sizeof(struct cvec));
56  cv->ranges = cv->chrs + nchrs;
57  cv->rangespace = nranges;
58  return clearcvec(cv);
59 }
#define MALLOC(n)
Definition: regcustom.h:52
pg_wchar chr
Definition: regcustom.h:59
Definition: regguts.h:279

References cvec::chrs, cvec::chrspace, clearcvec(), MALLOC, cvec::nchrs, cvec::nranges, cvec::ranges, and cvec::rangespace.

Referenced by getcvec().