PostgreSQL Source Code git master
Loading...
Searching...
No Matches
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 82 of file regc_cvec.c.

84{
85 assert(cv->nchrs < cv->chrspace);
86 cv->chrs[cv->nchrs++] = c;
87}
char * c
#define assert(x)
Definition regcustom.h:59
int chrspace
Definition regguts.h:289
int nchrs
Definition regguts.h:288
chr * chrs
Definition regguts.h:290

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 93 of file regc_cvec.c.

96{
97 assert(cv->nranges < cv->rangespace);
98 cv->ranges[cv->nranges * 2] = from;
99 cv->ranges[cv->nranges * 2 + 1] = to;
100 cv->nranges++;
101}
int rangespace
Definition regguts.h:292
chr * ranges
Definition regguts.h:293
int nranges
Definition regguts.h:291

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 69 of file regc_cvec.c.

70{
71 assert(cv != NULL);
72 cv->nchrs = 0;
73 cv->nranges = 0;
74 cv->cclasscode = -1;
75 return cv;
76}
static int fb(int x)
int cclasscode
Definition regguts.h:294

References assert, cvec::cclasscode, fb(), cvec::nchrs, and cvec::nranges.

Referenced by getcvec(), and newcvec().

◆ freecvec()

static void freecvec ( struct cvec cv)
static

Definition at line 138 of file regc_cvec.c.

139{
140 FREE(cv);
141}
#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 115 of file regc_cvec.c.

118{
119 /* recycle existing transient cvec if large enough */
120 if (v->cv != NULL && nchrs <= v->cv->chrspace &&
121 nranges <= v->cv->rangespace)
122 return clearcvec(v->cv);
123
124 /* nope, make a new one */
125 if (v->cv != NULL)
126 freecvec(v->cv);
127 v->cv = newcvec(nchrs, nranges);
128 if (v->cv == NULL)
130
131 return v->cv;
132}
#define ERR
Definition _int.h:161
static void freecvec(struct cvec *cv)
Definition regc_cvec.c:138
static struct cvec * newcvec(int nchrs, int nranges)
Definition regc_cvec.c:48
static struct cvec * clearcvec(struct cvec *cv)
Definition regc_cvec.c:69
#define REG_ESPACE
Definition regex.h:227
struct cvec * cv
Definition regcomp.c:304

References cvec::chrspace, clearcvec(), vars::cv, ERR, fb(), 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 48 of file regc_cvec.c.

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

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

Referenced by getcvec().