[fix] Moving address_parser_response_destroy into libpostal so caller can free
This commit is contained in:
@@ -801,31 +801,6 @@ address_parser_response_t *address_parser_response_new(void) {
|
||||
return response;
|
||||
}
|
||||
|
||||
void address_parser_response_destroy(address_parser_response_t *self) {
|
||||
if (self == NULL) return;
|
||||
|
||||
for (int i = 0; i < self->num_components; i++) {
|
||||
if (self->components != NULL) {
|
||||
free(self->components[i]);
|
||||
}
|
||||
|
||||
if (self->labels != NULL) {
|
||||
free(self->labels[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (self->components != NULL) {
|
||||
free(self->components);
|
||||
}
|
||||
|
||||
if (self->labels != NULL) {
|
||||
free(self->labels);
|
||||
}
|
||||
|
||||
free(self);
|
||||
}
|
||||
|
||||
|
||||
address_parser_response_t *address_parser_parse(char *address, char *language, char *country, address_parser_context_t *context) {
|
||||
if (address == NULL || context == NULL) return NULL;
|
||||
|
||||
|
||||
@@ -139,7 +139,6 @@ address_parser_t *address_parser_new(void);
|
||||
address_parser_t *get_address_parser(void);
|
||||
bool address_parser_load(char *dir);
|
||||
|
||||
void address_parser_response_destroy(address_parser_response_t *self);
|
||||
address_parser_response_t *address_parser_parse(char *address, char *language, char *country, address_parser_context_t *context);
|
||||
void address_parser_destroy(address_parser_t *self);
|
||||
|
||||
|
||||
@@ -822,6 +822,32 @@ char **expand_address(char *input, normalize_options_t options, size_t *n) {
|
||||
|
||||
}
|
||||
|
||||
void address_parser_response_destroy(address_parser_response_t *self) {
|
||||
if (self == NULL) return;
|
||||
|
||||
for (int i = 0; i < self->num_components; i++) {
|
||||
if (self->components != NULL) {
|
||||
free(self->components[i]);
|
||||
}
|
||||
|
||||
if (self->labels != NULL) {
|
||||
free(self->labels[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (self->components != NULL) {
|
||||
free(self->components);
|
||||
}
|
||||
|
||||
if (self->labels != NULL) {
|
||||
free(self->labels);
|
||||
}
|
||||
|
||||
free(self);
|
||||
}
|
||||
|
||||
|
||||
|
||||
address_parser_response_t *parse_address(char *address, address_parser_options_t options) {
|
||||
address_parser_context_t *context = address_parser_context_new();
|
||||
address_parser_response_t *parsed = address_parser_parse(address, options.language, options.country, context);
|
||||
|
||||
@@ -107,8 +107,12 @@ static address_parser_options_t LIBPOSTAL_ADDRESS_PARSER_DEFAULT_OPTIONS = {
|
||||
.country = NULL
|
||||
};
|
||||
|
||||
void address_parser_response_destroy(address_parser_response_t *self);
|
||||
|
||||
address_parser_response_t *parse_address(char *address, address_parser_options_t options);
|
||||
|
||||
|
||||
|
||||
// Setup/teardown methods
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user