Commit a8e77732 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp Committed by Tollef Fog Heen

A quick style polish

parent d04d9c99
...@@ -38,41 +38,47 @@ struct vre { ...@@ -38,41 +38,47 @@ struct vre {
pcre *re; pcre *re;
}; };
vre_t *VRE_compile(const char *pattern, int options, vre_t *
const char **errptr, int *erroffset) { VRE_compile(const char *pattern, int options,
const char **errptr, int *erroffset)
{
vre_t *v; vre_t *v;
*errptr = NULL; *erroffset = 0; *errptr = NULL; *erroffset = 0;
ALLOC_OBJ(v, VRE_MAGIC); ALLOC_OBJ(v, VRE_MAGIC);
AN(v); if (v == NULL)
return (NULL);
v->re = pcre_compile(pattern, options, errptr, erroffset, NULL); v->re = pcre_compile(pattern, options, errptr, erroffset, NULL);
if (v->re == NULL) { if (v->re == NULL) {
VRE_free(&v); VRE_free(&v);
return NULL; return (NULL);
} }
return v; return (v);
} }
int VRE_exec(const vre_t *code, const char *subject, int length, int
int startoffset, int options, int *ovector, int ovecsize) { VRE_exec(const vre_t *code, const char *subject, int length,
int startoffset, int options, int *ovector, int ovecsize)
{
CHECK_OBJ_NOTNULL(code, VRE_MAGIC); CHECK_OBJ_NOTNULL(code, VRE_MAGIC);
int ov[30]; int ov[30];
if (ovector == NULL) { if (ovector == NULL) {
ovector = ov; ovector = ov;
ovecsize = sizeof(ov)/sizeof(ov[0]); ovecsize = sizeof(ov)/sizeof(ov[0]);
} }
return pcre_exec(code->re, NULL, subject, length, return (pcre_exec(code->re, NULL, subject, length,
startoffset, options, ovector, ovecsize); startoffset, options, ovector, ovecsize));
} }
void VRE_free(vre_t **vv) { void
VRE_free(vre_t **vv)
{
vre_t *v = *vv; vre_t *v = *vv;
*vv = NULL; *vv = NULL;
CHECK_OBJ(v, VRE_MAGIC); CHECK_OBJ(v, VRE_MAGIC);
pcre_free(v->re); pcre_free(v->re);
v->magic = 0;
FREE_OBJ(v); FREE_OBJ(v);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment