diff --git a/lib/parse.c b/lib/parse.c index 5d5f717..a5bdd22 100644 --- a/lib/parse.c +++ b/lib/parse.c @@ -5,6 +5,7 @@ #include "parse.h" +#include #include #define CLASS_START_CAPACITY 4 @@ -62,15 +63,13 @@ static int parse_class(const char *input, int rem, regex_class_t *out) out->count = 0; out->capacity = CLASS_START_CAPACITY; out->contents = malloc(out->capacity); - if (NULL == out->contents) - return -1; + assert(NULL != out->contents); while (used < rem) { if (out->count >= out->capacity) { out->capacity *= 2; out->contents = realloc(out->contents, out->capacity); - if (NULL == out->contents) - return -1; + assert(NULL != out->contents); } result = parse_literal( @@ -155,16 +154,14 @@ static int parse_sequence(const char *input, int rem, regex_sequence_t *out) out->count = 0; out->capacity = SEQUENCE_START_CAPACITY; out->contents = malloc(out->capacity * sizeof(regex_term_t)); - if (NULL == out->contents) - return -1; + assert(NULL != out->contents); while (used < rem) { if (out->count >= out->capacity) { out->capacity *= 2; out->contents = realloc( out->contents, out->capacity * sizeof(regex_term_t)); - if (NULL == out->contents) - return -1; + assert(NULL != out->contents); } result = parse_term( @@ -185,8 +182,7 @@ int parse_expr(const char *input, int rem, regex_t *out) out->count = 0; out->capacity = TREE_START_CAPACITY; out->contents = malloc(out->capacity * sizeof(regex_sequence_t)); - if (NULL == out->contents) - return -1; + assert(NULL != out->contents); result = parse_sequence(input + used, rem - used, &out->contents[0]); if (result < 0) @@ -203,8 +199,7 @@ int parse_expr(const char *input, int rem, regex_t *out) out->capacity *= 2; out->contents = realloc( out->contents, out->capacity * sizeof(regex_sequence_t)); - if (NULL == out->contents) - return -1; + assert(NULL != out->contents); } result = parse_sequence(