Call destroy function for selectors list https://github.com/lexborisov/Modest/issues/3

This commit is contained in:
lexborisov 2016-11-21 14:07:37 +03:00
parent a7345ef5e0
commit 58dcf7ec02
5 changed files with 14 additions and 13 deletions

View File

@ -81,10 +81,8 @@ int main(int argc, const char * argv[])
modest_finder_t *finder = modest_finder_create_simple(html_tree, NULL);
mycss_selectors_list_t *list = mycss_selectors_parse(css_entry->selectors, MyHTML_ENCODING_UTF_8, selector, strlen(selector), &out_status);
myhtml_collection_t *collection = modest_finder_by_selectors_list(finder, list, html_tree->node_html, NULL);
/* destroy Modest finder */
modest_finder_destroy(finder, true);
myhtml_collection_t *collection = modest_finder_by_selectors_list(finder, list, html_tree->node_html, NULL);
/* print result */
fprintf(stdout, "HTML Tree:\n");
@ -103,6 +101,12 @@ int main(int argc, const char * argv[])
fprintf(stdout, "\n");
// destroy all
mycss_selectors_list_destroy(css_entry->selectors, list, true);
myhtml_collection_destroy(collection);
/* destroy Modest finder */
modest_finder_destroy(finder, true);
mycss_t *mycss = css_entry->mycss;
mycss_entry_destroy(css_entry, true);
mycss_destroy(mycss, true);

View File

@ -53,7 +53,7 @@ void modest_node_raw_serialization_callback(myhtml_utils_avl_tree_node_t* node,
modest_node_serialization_context_t *ctx = context;
modest_style_raw_declaration_t *raw_declr = node->value;
modest_node_raw_serialization_declaration(ctx->modest->mycss_entry, raw_declr->declaration, node->type, ctx->callback, ctx->context, &ctx->is_use);
modest_node_raw_serialization_declaration(ctx->modest->mycss_entry, raw_declr->declaration, (mycss_property_type_t)node->type, ctx->callback, ctx->context, &ctx->is_use);
}
bool modest_node_raw_serialization(modest_t* modest, modest_node_t* mnode, mycss_callback_serialization_f callback, void* context)

View File

@ -115,6 +115,7 @@ mycss_status_t mycss_entry_init(mycss_t* mycss, mycss_entry_t* entry)
mycss_status_t mycss_entry_clean(mycss_entry_t* entry)
{
mcobject_clean(entry->mcobject_incoming_buffer);
mycss_entry_parser_list_clean(entry->parser_list);
/* CSS Modules */

View File

@ -46,14 +46,10 @@ mycss_selectors_list_t * mycss_selectors_list_destroy(mycss_selectors_t* selecto
mycss_selectors_entry_t *sel_entry = selectors_list->entries_list[i].entry;
while(sel_entry) {
if(sel_entry->next) {
sel_entry = sel_entry->next;
mycss_selectors_entry_destroy(entry->selectors, sel_entry->prev, true);
}
else {
mycss_selectors_entry_destroy(entry->selectors, sel_entry, true);
break;
}
mycss_selectors_entry_t *sel_entry_next = sel_entry->next;
mycss_selectors_entry_destroy(entry->selectors, sel_entry, true);
sel_entry = sel_entry_next;
}
}

View File

@ -52,7 +52,7 @@ myhtml_string_t * myhtml_string_destroy(myhtml_string_t* str, bool destroy_obj)
if(str == NULL)
return NULL;
if(str->data && str->mchar && str->node_idx)
if(str->data && str->mchar)
mchar_async_free(str->mchar, str->node_idx, str->data);
if(destroy_obj && str) {