PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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

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

Definition at line 79 of file regc_cvec.c.

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

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

81 {
82  assert(cv->nchrs < cv->chrspace);
83  cv->chrs[cv->nchrs++] = c;
84 }
int chrspace
Definition: regguts.h:259
int nchrs
Definition: regguts.h:258
char * c
#define assert(TEST)
Definition: imath.c:37
chr * chrs
Definition: regguts.h:260
static void addrange ( struct cvec cv,
chr  from,
chr  to 
)
static

Definition at line 90 of file regc_cvec.c.

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

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

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 }
struct state * from
Definition: regguts.h:280
chr * ranges
Definition: regguts.h:263
#define assert(TEST)
Definition: imath.c:37
struct state * to
Definition: regguts.h:281
int rangespace
Definition: regguts.h:262
int nranges
Definition: regguts.h:261
static struct cvec* clearcvec ( struct cvec cv)
static

Definition at line 66 of file regc_cvec.c.

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

Referenced by getcvec(), and newcvec().

67 {
68  assert(cv != NULL);
69  cv->nchrs = 0;
70  cv->nranges = 0;
71  cv->cclasscode = -1;
72  return cv;
73 }
int nchrs
Definition: regguts.h:258
int cclasscode
Definition: regguts.h:264
#define assert(TEST)
Definition: imath.c:37
#define NULL
Definition: c.h:226
int nranges
Definition: regguts.h:261
static void freecvec ( struct cvec cv)
static

Definition at line 135 of file regc_cvec.c.

References FREE.

Referenced by getcvec().

136 {
137  FREE(cv);
138 }
#define FREE(p)
Definition: regcustom.h:54
static struct cvec* getcvec ( struct vars v,
int  nchrs,
int  nranges 
)
static

Definition at line 112 of file regc_cvec.c.

References clearcvec(), vars::cv, ERR, freecvec(), newcvec(), NULL, and REG_ESPACE.

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

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:146
#define REG_ESPACE
Definition: regex.h:149
static struct cvec * newcvec(int nchrs, int nranges)
Definition: regc_cvec.c:45
static struct cvec * clearcvec(struct cvec *cv)
Definition: regc_cvec.c:66
struct cvec * cv
Definition: regcomp.c:251
static void freecvec(struct cvec *cv)
Definition: regc_cvec.c:135
#define NULL
Definition: c.h:226
static struct cvec* newcvec ( int  nchrs,
int  nranges 
)
static

Definition at line 45 of file regc_cvec.c.

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

Referenced by getcvec().

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 }
int chrspace
Definition: regguts.h:259
#define MALLOC(n)
Definition: regcustom.h:53
pg_wchar chr
Definition: regcustom.h:59
static struct cvec * clearcvec(struct cvec *cv)
Definition: regc_cvec.c:66
chr * ranges
Definition: regguts.h:263
int nchrs
Definition: regguts.h:258
Definition: regguts.h:256
chr * chrs
Definition: regguts.h:260
#define NULL
Definition: c.h:226
int rangespace
Definition: regguts.h:262
int nranges
Definition: regguts.h:261