diff --git a/src/address_parser_io.c b/src/address_parser_io.c index d0ea6630..8d6325f2 100644 --- a/src/address_parser_io.c +++ b/src/address_parser_io.c @@ -51,13 +51,12 @@ bool address_parser_data_set_tokenize_line(address_parser_data_set_t *data_set, label = str + last_separator_index + 1; - uint32_t last_separator_type = ADDRESS_SEPARATOR_NONE; if (strcmp(label, FIELD_SEPARATOR_LABEL) == 0) { - last_separator_type = uint32_array_pop(separators); + uint32_array_pop(separators); uint32_array_push(separators, ADDRESS_SEPARATOR_FIELD | ADDRESS_SEPARATOR_FIELD_INTERNAL); continue; } else if (strcmp(label, SEPARATOR_LABEL) == 0) { - last_separator_type = uint32_array_pop(separators); + uint32_array_pop(separators); uint32_array_push(separators, ADDRESS_SEPARATOR_FIELD_INTERNAL); continue; } diff --git a/src/vector.h b/src/vector.h index b56f5dca..c431165c 100644 --- a/src/vector.h +++ b/src/vector.h @@ -11,7 +11,6 @@ name *array = malloc(sizeof(name)); \ if (array == NULL) return NULL; \ array->n = array->m = 0; \ - array->a = NULL; \ array->a = malloc(size * sizeof(type)); \ if (array->a == NULL) return NULL; \ array->m = size; \ @@ -39,12 +38,12 @@ } \ static inline void name##_extend(name *array, name *other) { \ size_t new_size = array->n + other->n; \ - if (new_size >= array->m) name##_resize(array, new_size); \ + if (new_size > array->m) name##_resize(array, new_size); \ memcpy(array->a + array->n, other->a, other->n * sizeof(type)); \ array->n = new_size; \ } \ - static inline type name##_pop(name *array) { \ - return array->a[--array->n]; \ + static inline void name##_pop(name *array) { \ + if (array->n > 0) array->n--; \ } \ static inline void name##_clear(name *array) { \ array->n = 0; \