void gumbo_error_destroy(GumboParser* parser, GumboError* error) { if (error->type == GUMBO_ERR_PARSER || error->type == GUMBO_ERR_UNACKNOWLEDGED_SELF_CLOSING_TAG) { gumbo_vector_destroy(parser, &error->v.parser.tag_stack); } else if (error->type == GUMBO_ERR_DUPLICATE_ATTR) { gumbo_parser_deallocate(parser, (void*) error->v.duplicate_attr.name); } gumbo_parser_deallocate(parser, error); }
static void enlarge_vector_if_full( struct GumboInternalParser* parser, GumboVector* vector) { if (vector->length >= vector->capacity) { if (vector->capacity) { size_t old_num_bytes = sizeof(void*) * vector->capacity; vector->capacity *= 2; size_t num_bytes = sizeof(void*) * vector->capacity; void** temp = (void**)gumbo_parser_allocate(parser, num_bytes); memcpy(temp, vector->data, old_num_bytes); gumbo_parser_deallocate(parser, vector->data); vector->data = temp; } else { // 0-capacity vector; no previous array to deallocate. vector->capacity = 2; vector->data = (void**)gumbo_parser_allocate( parser, sizeof(void*) * vector->capacity); } } }
void gumbo_destroy_attribute( struct GumboInternalParser* parser, GumboAttribute* attribute) { gumbo_parser_deallocate(parser, (void*) attribute->name); gumbo_parser_deallocate(parser, (void*) attribute->value); gumbo_parser_deallocate(parser, (void*) attribute); }
void gumbo_vector_destroy(struct GumboInternalParser* parser, GumboVector* vector) { if (vector->capacity > 0) { gumbo_parser_deallocate(parser, vector->data); } }