diff options
author | lexborisov <lex.borisov@gmail.com> | 2017-03-21 09:56:42 +0300 |
---|---|---|
committer | lexborisov <lex.borisov@gmail.com> | 2017-03-21 09:56:42 +0300 |
commit | 7024458c55c0baedfb29c2f9db213d3b0474c851 (patch) | |
tree | 7ec10676fc5a24bffed67d9f6f89ba14130ea781 /source/myhtml/myhtml.c | |
parent | 0708dba577f51a9cb504db1feeb094aa9badd795 (diff) |
Merge branch 'master' into coverity_scancoverity_scan
Diffstat (limited to 'source/myhtml/myhtml.c')
-rw-r--r-- | source/myhtml/myhtml.c | 409 |
1 files changed, 236 insertions, 173 deletions
diff --git a/source/myhtml/myhtml.c b/source/myhtml/myhtml.c index 767603e..479f33e 100644 --- a/source/myhtml/myhtml.c +++ b/source/myhtml/myhtml.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2015-2016 Alexander Borisov + Copyright (C) 2015-2017 Alexander Borisov This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -22,7 +22,7 @@ void myhtml_init_marker(myhtml_t* myhtml) { - myhtml->marker = (myhtml_tree_node_t*)myhtml_malloc(sizeof(myhtml_tree_node_t)); + myhtml->marker = (myhtml_tree_node_t*)mycore_malloc(sizeof(myhtml_tree_node_t)); if(myhtml->marker) myhtml_tree_node_clean(myhtml->marker); @@ -31,92 +31,152 @@ void myhtml_init_marker(myhtml_t* myhtml) void myhtml_destroy_marker(myhtml_t* myhtml) { if(myhtml->marker) - myhtml_free(myhtml->marker); + mycore_free(myhtml->marker); } -myhtml_t * myhtml_create(void) +#ifndef MyCORE_BUILD_WITHOUT_THREADS +mystatus_t myhtml_stream_create(myhtml_t* myhtml, mystatus_t* status, size_t count, size_t id_increase) { - return (myhtml_t*)myhtml_malloc(sizeof(myhtml_t)); + if(count == 0) { + myhtml->thread_stream = NULL; + + *status = MyHTML_STATUS_OK; + return *status; + } + + myhtml->thread_stream = mythread_create(); + if(myhtml->thread_stream == NULL) + *status = MyCORE_STATUS_THREAD_ERROR_MEMORY_ALLOCATION; + + *status = mythread_init(myhtml->thread_stream, MyTHREAD_TYPE_STREAM, count, id_increase); + + if(*status) + myhtml->thread_stream = mythread_destroy(myhtml->thread_stream, NULL, NULL, true); + + return *status; } -myhtml_status_t myhtml_init(myhtml_t* myhtml, enum myhtml_options opt, size_t thread_count, size_t queue_size) +mystatus_t myhtml_batch_create(myhtml_t* myhtml, mystatus_t* status, size_t count, size_t id_increase) { - myhtml_status_t status; + if(count == 0) { + myhtml->thread_batch = NULL; + + *status = MyHTML_STATUS_OK; + return *status; + } - myhtml_init_marker(myhtml); + myhtml->thread_batch = mythread_create(); + if(myhtml->thread_stream == NULL) { + myhtml->thread_stream = mythread_destroy(myhtml->thread_stream, NULL, NULL, true); + *status = MyCORE_STATUS_THREAD_ERROR_MEMORY_ALLOCATION; + } - status = myhtml_tokenizer_state_init(myhtml); - if(status) { - myhtml->insertion_func = NULL; - myhtml->thread = NULL; - + *status = mythread_init(myhtml->thread_batch, MyTHREAD_TYPE_BATCH, count, id_increase); + + if(*status) + myhtml->thread_batch = mythread_destroy(myhtml->thread_batch , NULL, NULL, true); + + return *status; +} + +mystatus_t myhtml_create_stream_and_batch(myhtml_t* myhtml, size_t stream_count, size_t batch_count) +{ + mystatus_t status; + + /* stream */ + if(myhtml_stream_create(myhtml, &status, stream_count, 0)) { return status; } - status = myhtml_rules_init(myhtml); - if(status) { - myhtml->thread = NULL; - + /* batch */ + if(myhtml_batch_create(myhtml, &status, batch_count, stream_count)) { + myhtml->thread_stream = mythread_destroy(myhtml->thread_stream, NULL, NULL, true); return status; } + return status; +} +#endif /* if undef MyCORE_BUILD_WITHOUT_THREADS */ + +myhtml_t * myhtml_create(void) +{ + return (myhtml_t*)mycore_calloc(1, sizeof(myhtml_t)); +} + +mystatus_t myhtml_init(myhtml_t* myhtml, enum myhtml_options opt, size_t thread_count, size_t queue_size) +{ + mystatus_t status; + myhtml->opt = opt; - myhtml->thread = mythread_create(); + myhtml_init_marker(myhtml); - if(myhtml->thread == NULL) - return MyHTML_STATUS_THREAD_ERROR_MEMORY_ALLOCATION; + status = myhtml_tokenizer_state_init(myhtml); + if(status) + return status; -#ifdef MyHTML_BUILD_WITHOUT_THREADS + status = myhtml_rules_init(myhtml); + +#ifdef MyCORE_BUILD_WITHOUT_THREADS - status = mythread_init(myhtml->thread, NULL, thread_count); + myhtml->thread_stream = NULL; + myhtml->thread_batch = NULL; + myhtml->thread_total = 0; +#else /* if undef MyCORE_BUILD_WITHOUT_THREADS */ if(status) return status; -#else /* MyHTML_BUILD_WITHOUT_THREADS */ switch (opt) { case MyHTML_OPTIONS_PARSE_MODE_SINGLE: - status = mythread_init(myhtml->thread, "lastmac", 0); - if(status) - return status; - - myhtml->thread->context = mythread_queue_list_create(&status); - if(status) + if((status = myhtml_create_stream_and_batch(myhtml, 0, 0))) return status; break; case MyHTML_OPTIONS_PARSE_MODE_ALL_IN_ONE: - status = mythread_init(myhtml->thread, "lastmac", 1); - if(status) + if((status = myhtml_create_stream_and_batch(myhtml, 1, 0))) return status; - myhtml->thread->context = mythread_queue_list_create(&status); - if(status) - return status; + myhtml->thread_stream->context = mythread_queue_list_create(&status); + status = myhread_entry_create(myhtml->thread_stream, mythread_function_queue_stream, myhtml_parser_worker_stream, MyTHREAD_OPT_STOP); - myhread_create_stream(myhtml->thread, mythread_function_queue_stream, myhtml_parser_worker_stream, MyTHREAD_OPT_STOP, &status); break; default: // default MyHTML_OPTIONS_PARSE_MODE_SEPARATELY - if(thread_count == 0) - thread_count = 1; + if(thread_count < 2) + thread_count = 2; - status = mythread_init(myhtml->thread, "lastmac", (thread_count + 1)); - if(status) + if((status = myhtml_create_stream_and_batch(myhtml, 1, (thread_count - 1)))) return status; - myhtml->thread->context = mythread_queue_list_create(&status); + myhtml->thread_stream->context = mythread_queue_list_create(&status); + myhtml->thread_batch->context = myhtml->thread_stream->context; + + status = myhread_entry_create(myhtml->thread_stream, mythread_function_queue_stream, myhtml_parser_stream, MyTHREAD_OPT_STOP); if(status) return status; - myhread_create_stream(myhtml->thread, mythread_function_queue_stream, myhtml_parser_stream, MyTHREAD_OPT_STOP, &status); - myhread_create_batch(myhtml->thread, mythread_function_queue_batch, myhtml_parser_worker, MyTHREAD_OPT_STOP, &status, thread_count); + for(size_t i = 0; i < myhtml->thread_batch->entries_size; i++) { + status = myhread_entry_create(myhtml->thread_batch, mythread_function_queue_batch, myhtml_parser_worker, MyTHREAD_OPT_STOP); + + if(status) + return status; + } + break; } -#endif /* MyHTML_BUILD_WITHOUT_THREADS */ + myhtml->thread_total = thread_count; + + myhtml->thread_list[0] = myhtml->thread_stream; + myhtml->thread_list[1] = myhtml->thread_batch; + myhtml->thread_list[2] = NULL; + +#endif /* if undef MyCORE_BUILD_WITHOUT_THREADS */ + + if(status) + return status; myhtml_clean(myhtml); @@ -125,7 +185,7 @@ myhtml_status_t myhtml_init(myhtml_t* myhtml, enum myhtml_options opt, size_t th void myhtml_clean(myhtml_t* myhtml) { - mythread_clean(myhtml->thread); + /* some code */ } myhtml_t* myhtml_destroy(myhtml_t* myhtml) @@ -135,36 +195,41 @@ myhtml_t* myhtml_destroy(myhtml_t* myhtml) myhtml_destroy_marker(myhtml); - if(myhtml->thread) { -#ifndef MyHTML_BUILD_WITHOUT_THREADS - mythread_queue_list_t* queue_list = myhtml->thread->context; -#endif +#ifndef MyCORE_BUILD_WITHOUT_THREADS + if(myhtml->thread_stream) { + mythread_queue_list_t* queue_list = myhtml->thread_stream->context; + + if(queue_list) + mythread_queue_list_wait_for_done(myhtml->thread_stream, queue_list); - myhtml->thread = mythread_destroy(myhtml->thread, mythread_queue_wait_all_for_done, true); + myhtml->thread_stream = mythread_destroy(myhtml->thread_stream, mythread_callback_quit, NULL, true); -#ifndef MyHTML_BUILD_WITHOUT_THREADS - mythread_queue_list_destroy(queue_list); -#endif + if(myhtml->thread_batch) + myhtml->thread_batch = mythread_destroy(myhtml->thread_batch, mythread_callback_quit, NULL, true); + + if(queue_list) + mythread_queue_list_destroy(queue_list); } +#endif /* if undef MyCORE_BUILD_WITHOUT_THREADS */ myhtml_tokenizer_state_destroy(myhtml); if(myhtml->insertion_func) - myhtml_free(myhtml->insertion_func); + mycore_free(myhtml->insertion_func); - myhtml_free(myhtml); + mycore_free(myhtml); return NULL; } -myhtml_status_t myhtml_parse(myhtml_tree_t* tree, myhtml_encoding_t encoding, const char* html, size_t html_size) +mystatus_t myhtml_parse(myhtml_tree_t* tree, myencoding_t encoding, const char* html, size_t html_size) { if(tree->flags & MyHTML_TREE_FLAGS_PARSE_END) { myhtml_tree_clean(tree); } myhtml_encoding_set(tree, encoding); - myhtml_status_t status = myhtml_tokenizer_begin(tree, html, html_size); + mystatus_t status = myhtml_tokenizer_begin(tree, html, html_size); if(status) return status; @@ -172,7 +237,7 @@ myhtml_status_t myhtml_parse(myhtml_tree_t* tree, myhtml_encoding_t encoding, co return myhtml_tokenizer_end(tree); } -myhtml_status_t myhtml_parse_fragment(myhtml_tree_t* tree, myhtml_encoding_t encoding, const char* html, size_t html_size, myhtml_tag_id_t tag_id, enum myhtml_namespace ns) +mystatus_t myhtml_parse_fragment(myhtml_tree_t* tree, myencoding_t encoding, const char* html, size_t html_size, myhtml_tag_id_t tag_id, enum myhtml_namespace ns) { if(tree->flags & MyHTML_TREE_FLAGS_PARSE_END) { myhtml_tree_clean(tree); @@ -188,7 +253,7 @@ myhtml_status_t myhtml_parse_fragment(myhtml_tree_t* tree, myhtml_encoding_t enc return MyHTML_STATUS_TOKENIZER_ERROR_FRAGMENT_INIT; myhtml_encoding_set(tree, encoding); - myhtml_status_t status = myhtml_tokenizer_begin(tree, html, html_size); + mystatus_t status = myhtml_tokenizer_begin(tree, html, html_size); if(status) return status; @@ -196,7 +261,7 @@ myhtml_status_t myhtml_parse_fragment(myhtml_tree_t* tree, myhtml_encoding_t enc return myhtml_tokenizer_end(tree); } -myhtml_status_t myhtml_parse_single(myhtml_tree_t* tree, myhtml_encoding_t encoding, const char* html, size_t html_size) +mystatus_t myhtml_parse_single(myhtml_tree_t* tree, myencoding_t encoding, const char* html, size_t html_size) { if(tree->flags & MyHTML_TREE_FLAGS_PARSE_END) { myhtml_tree_clean(tree); @@ -206,7 +271,7 @@ myhtml_status_t myhtml_parse_single(myhtml_tree_t* tree, myhtml_encoding_t encod myhtml_encoding_set(tree, encoding); - myhtml_status_t status = myhtml_tokenizer_begin(tree, html, html_size); + mystatus_t status = myhtml_tokenizer_begin(tree, html, html_size); if(status) return status; @@ -214,7 +279,7 @@ myhtml_status_t myhtml_parse_single(myhtml_tree_t* tree, myhtml_encoding_t encod return myhtml_tokenizer_end(tree); } -myhtml_status_t myhtml_parse_fragment_single(myhtml_tree_t* tree, myhtml_encoding_t encoding, const char* html, size_t html_size, myhtml_tag_id_t tag_id, enum myhtml_namespace ns) +mystatus_t myhtml_parse_fragment_single(myhtml_tree_t* tree, myencoding_t encoding, const char* html, size_t html_size, myhtml_tag_id_t tag_id, enum myhtml_namespace ns) { if(tree->flags & MyHTML_TREE_FLAGS_PARSE_END) { myhtml_tree_clean(tree); @@ -233,7 +298,7 @@ myhtml_status_t myhtml_parse_fragment_single(myhtml_tree_t* tree, myhtml_encodin myhtml_encoding_set(tree, encoding); - myhtml_status_t status = myhtml_tokenizer_begin(tree, html, html_size); + mystatus_t status = myhtml_tokenizer_begin(tree, html, html_size); if(status) return status; @@ -241,7 +306,7 @@ myhtml_status_t myhtml_parse_fragment_single(myhtml_tree_t* tree, myhtml_encodin return myhtml_tokenizer_end(tree); } -myhtml_status_t myhtml_parse_chunk(myhtml_tree_t* tree, const char* html, size_t html_size) +mystatus_t myhtml_parse_chunk(myhtml_tree_t* tree, const char* html, size_t html_size) { if(tree->flags & MyHTML_TREE_FLAGS_PARSE_END) { myhtml_tree_clean(tree); @@ -250,7 +315,7 @@ myhtml_status_t myhtml_parse_chunk(myhtml_tree_t* tree, const char* html, size_t return myhtml_tokenizer_chunk(tree, html, html_size); } -myhtml_status_t myhtml_parse_chunk_fragment(myhtml_tree_t* tree, const char* html, size_t html_size, myhtml_tag_id_t tag_id, enum myhtml_namespace ns) +mystatus_t myhtml_parse_chunk_fragment(myhtml_tree_t* tree, const char* html, size_t html_size, myhtml_tag_id_t tag_id, enum myhtml_namespace ns) { if(tree->flags & MyHTML_TREE_FLAGS_PARSE_END) { myhtml_tree_clean(tree); @@ -268,7 +333,7 @@ myhtml_status_t myhtml_parse_chunk_fragment(myhtml_tree_t* tree, const char* htm return myhtml_tokenizer_chunk(tree, html, html_size); } -myhtml_status_t myhtml_parse_chunk_single(myhtml_tree_t* tree, const char* html, size_t html_size) +mystatus_t myhtml_parse_chunk_single(myhtml_tree_t* tree, const char* html, size_t html_size) { if((tree->flags & MyHTML_TREE_FLAGS_SINGLE_MODE) == 0) tree->flags |= MyHTML_TREE_FLAGS_SINGLE_MODE; @@ -276,7 +341,7 @@ myhtml_status_t myhtml_parse_chunk_single(myhtml_tree_t* tree, const char* html, return myhtml_parse_chunk(tree, html, html_size); } -myhtml_status_t myhtml_parse_chunk_fragment_single(myhtml_tree_t* tree, const char* html, size_t html_size, myhtml_tag_id_t tag_id, enum myhtml_namespace ns) +mystatus_t myhtml_parse_chunk_fragment_single(myhtml_tree_t* tree, const char* html, size_t html_size, myhtml_tag_id_t tag_id, enum myhtml_namespace ns) { if((tree->flags & MyHTML_TREE_FLAGS_SINGLE_MODE) == 0) tree->flags |= MyHTML_TREE_FLAGS_SINGLE_MODE; @@ -284,21 +349,21 @@ myhtml_status_t myhtml_parse_chunk_fragment_single(myhtml_tree_t* tree, const ch return myhtml_parse_chunk_fragment(tree, html, html_size, tag_id, ns); } -myhtml_status_t myhtml_parse_chunk_end(myhtml_tree_t* tree) +mystatus_t myhtml_parse_chunk_end(myhtml_tree_t* tree) { return myhtml_tokenizer_end(tree); } -void myhtml_encoding_set(myhtml_tree_t* tree, myhtml_encoding_t encoding) +void myhtml_encoding_set(myhtml_tree_t* tree, myencoding_t encoding) { - if(encoding >= MyHTML_ENCODING_LAST_ENTRY) + if(encoding >= MyENCODING_LAST_ENTRY) return; tree->encoding_usereq = encoding; tree->encoding = encoding; } -myhtml_encoding_t myhtml_encoding_get(myhtml_tree_t* tree) +myencoding_t myhtml_encoding_get(myhtml_tree_t* tree) { return tree->encoding; } @@ -307,7 +372,7 @@ myhtml_encoding_t myhtml_encoding_get(myhtml_tree_t* tree) * Nodes */ -myhtml_status_t myhtml_get_nodes_by_tag_id_in_scope_find_recursion(myhtml_tree_node_t *node, myhtml_collection_t *collection, myhtml_tag_id_t tag_id) +mystatus_t myhtml_get_nodes_by_tag_id_in_scope_find_recursion(myhtml_tree_node_t *node, myhtml_collection_t *collection, myhtml_tag_id_t tag_id) { while(node) { if(node->tag_id == tag_id) { @@ -316,7 +381,7 @@ myhtml_status_t myhtml_get_nodes_by_tag_id_in_scope_find_recursion(myhtml_tree_n if(collection->length >= collection->size) { - myhtml_status_t mystatus = myhtml_collection_check_size(collection, 1024, 0); + mystatus_t mystatus = myhtml_collection_check_size(collection, 1024, 0); if(mystatus != MyHTML_STATUS_OK) return mystatus; @@ -332,12 +397,12 @@ myhtml_status_t myhtml_get_nodes_by_tag_id_in_scope_find_recursion(myhtml_tree_n return MyHTML_STATUS_OK; } -myhtml_collection_t * myhtml_get_nodes_by_tag_id_in_scope(myhtml_tree_t* tree, myhtml_collection_t *collection, myhtml_tree_node_t *node, myhtml_tag_id_t tag_id, myhtml_status_t *status) +myhtml_collection_t * myhtml_get_nodes_by_tag_id_in_scope(myhtml_tree_t* tree, myhtml_collection_t *collection, myhtml_tree_node_t *node, myhtml_tag_id_t tag_id, mystatus_t *status) { if(node == NULL) return NULL; - myhtml_status_t mystatus = MyHTML_STATUS_OK; + mystatus_t mystatus = MyHTML_STATUS_OK; if(collection == NULL) { collection = myhtml_collection_create(1024, &mystatus); @@ -361,13 +426,13 @@ myhtml_collection_t * myhtml_get_nodes_by_tag_id_in_scope(myhtml_tree_t* tree, m return collection; } -myhtml_collection_t * myhtml_get_nodes_by_name_in_scope(myhtml_tree_t* tree, myhtml_collection_t *collection, myhtml_tree_node_t *node, const char* html, size_t length, myhtml_status_t *status) +myhtml_collection_t * myhtml_get_nodes_by_name_in_scope(myhtml_tree_t* tree, myhtml_collection_t *collection, myhtml_tree_node_t *node, const char* html, size_t length, mystatus_t *status) { const myhtml_tag_context_t *tag_ctx = myhtml_tag_get_by_name(tree->tags, html, length); return myhtml_get_nodes_by_tag_id_in_scope(tree, collection, node, tag_ctx->id, status); } -myhtml_collection_t * myhtml_get_nodes_by_tag_id(myhtml_tree_t* tree, myhtml_collection_t *collection, myhtml_tag_id_t tag_id, myhtml_status_t *status) +myhtml_collection_t * myhtml_get_nodes_by_tag_id(myhtml_tree_t* tree, myhtml_collection_t *collection, myhtml_tag_id_t tag_id, mystatus_t *status) { if(collection == NULL) { collection = myhtml_collection_create(1024, NULL); @@ -417,7 +482,7 @@ myhtml_collection_t * myhtml_get_nodes_by_tag_id(myhtml_tree_t* tree, myhtml_col return collection; } -myhtml_collection_t * myhtml_get_nodes_by_name(myhtml_tree_t* tree, myhtml_collection_t *collection, const char* html, size_t length, myhtml_status_t *status) +myhtml_collection_t * myhtml_get_nodes_by_name(myhtml_tree_t* tree, myhtml_collection_t *collection, const char* html, size_t length, mystatus_t *status) { const myhtml_tag_context_t *tag_ctx = myhtml_tag_get_by_name(tree->tags, html, length); @@ -546,12 +611,12 @@ myhtml_tree_node_t * myhtml_node_insert_to_appropriate_place(myhtml_tree_node_t return node; } -myhtml_string_t * myhtml_node_text_set(myhtml_tree_node_t *node, const char* text, size_t length, myhtml_encoding_t encoding) +mycore_string_t * myhtml_node_text_set(myhtml_tree_node_t *node, const char* text, size_t length, myencoding_t encoding) { if(node == NULL) return NULL; - if(encoding >= MyHTML_ENCODING_LAST_ENTRY) + if(encoding >= MyENCODING_LAST_ENTRY) return NULL; myhtml_tree_t* tree = node->tree; @@ -564,22 +629,22 @@ myhtml_string_t * myhtml_node_text_set(myhtml_tree_node_t *node, const char* tex } if(node->token->str.data == NULL) { - myhtml_string_init(tree->mchar, tree->mchar_node_id, &node->token->str, (length + 2)); + mycore_string_init(tree->mchar, tree->mchar_node_id, &node->token->str, (length + 2)); } else { if(node->token->str.size < length) { mchar_async_free(tree->mchar, node->token->str.node_idx, node->token->str.data); - myhtml_string_init(tree->mchar, tree->mchar_node_id, &node->token->str, length); + mycore_string_init(tree->mchar, tree->mchar_node_id, &node->token->str, length); } else node->token->str.length = 0; } - if(encoding != MyHTML_ENCODING_UTF_8) { - myhtml_string_append_with_convert_encoding(&node->token->str, text, length, encoding); + if(encoding != MyENCODING_UTF_8) { + myencoding_string_append(&node->token->str, text, length, encoding); } else { - myhtml_string_append(&node->token->str, text, length); + mycore_string_append(&node->token->str, text, length); } node->token->raw_begin = 0; @@ -588,12 +653,12 @@ myhtml_string_t * myhtml_node_text_set(myhtml_tree_node_t *node, const char* tex return &node->token->str; } -myhtml_string_t * myhtml_node_text_set_with_charef(myhtml_tree_node_t *node, const char* text, size_t length, myhtml_encoding_t encoding) +mycore_string_t * myhtml_node_text_set_with_charef(myhtml_tree_node_t *node, const char* text, size_t length, myencoding_t encoding) { if(node == NULL) return NULL; - if(encoding >= MyHTML_ENCODING_LAST_ENTRY) + if(encoding >= MyENCODING_LAST_ENTRY) return NULL; myhtml_tree_t* tree = node->tree; @@ -606,12 +671,12 @@ myhtml_string_t * myhtml_node_text_set_with_charef(myhtml_tree_node_t *node, con } if(node->token->str.data == NULL) { - myhtml_string_init(tree->mchar, tree->mchar_node_id, &node->token->str, (length + 2)); + mycore_string_init(tree->mchar, tree->mchar_node_id, &node->token->str, (length + 2)); } else { if(node->token->str.size < length) { mchar_async_free(tree->mchar, node->token->str.node_idx, node->token->str.data); - myhtml_string_init(tree->mchar, tree->mchar_node_id, &node->token->str, length); + mycore_string_init(tree->mchar, tree->mchar_node_id, &node->token->str, length); } else node->token->str.length = 0; @@ -621,7 +686,7 @@ myhtml_string_t * myhtml_node_text_set_with_charef(myhtml_tree_node_t *node, con myhtml_data_process_entry_clean(&proc_entry); proc_entry.encoding = encoding; - myhtml_encoding_result_clean(&proc_entry.res); + myencoding_result_clean(&proc_entry.res); myhtml_data_process(&proc_entry, &node->token->str, text, length); myhtml_data_process_end(&proc_entry, &node->token->str); @@ -724,7 +789,7 @@ const char * myhtml_node_text(myhtml_tree_node_t *node, size_t *length) return NULL; } -myhtml_string_t * myhtml_node_string(myhtml_tree_node_t *node) +mycore_string_t * myhtml_node_string(myhtml_tree_node_t *node) { if(node && node->token) return &node->token->str; @@ -763,7 +828,7 @@ myhtml_tree_t * myhtml_node_tree(myhtml_tree_node_t *node) return node->tree; } -myhtml_status_t myhtml_get_nodes_by_attribute_key_recursion(myhtml_tree_node_t* node, myhtml_collection_t* collection, const char* key, size_t key_len) +mystatus_t myhtml_get_nodes_by_attribute_key_recursion(myhtml_tree_node_t* node, myhtml_collection_t* collection, const char* key, size_t key_len) { while(node) { @@ -771,14 +836,14 @@ myhtml_status_t myhtml_get_nodes_by_attribute_key_recursion(myhtml_tree_node_t* myhtml_tree_attr_t* attr = node->token->attr_first; while(attr) { - myhtml_string_t* str_key = &attr->key; + mycore_string_t* str_key = &attr->key; - if(str_key->length == key_len && myhtml_strncasecmp(str_key->data, key, key_len) == 0) { + if(str_key->length == key_len && mycore_strncasecmp(str_key->data, key, key_len) == 0) { collection->list[ collection->length ] = node; collection->length++; if(collection->length >= collection->size) { - myhtml_status_t status = myhtml_collection_check_size(collection, 1024, 0); + mystatus_t status = myhtml_collection_check_size(collection, 1024, 0); if(status) return status; @@ -790,7 +855,7 @@ myhtml_status_t myhtml_get_nodes_by_attribute_key_recursion(myhtml_tree_node_t* } if(node->child) { - myhtml_status_t status = myhtml_get_nodes_by_attribute_key_recursion(node->child, collection, key, key_len); + mystatus_t status = myhtml_get_nodes_by_attribute_key_recursion(node->child, collection, key, key_len); if(status) return status; @@ -802,7 +867,7 @@ myhtml_status_t myhtml_get_nodes_by_attribute_key_recursion(myhtml_tree_node_t* return MyHTML_STATUS_OK; } -myhtml_collection_t * myhtml_get_nodes_by_attribute_key(myhtml_tree_t *tree, myhtml_collection_t* collection, myhtml_tree_node_t* scope_node, const char* key, size_t key_len, myhtml_status_t* status) +myhtml_collection_t * myhtml_get_nodes_by_attribute_key(myhtml_tree_t *tree, myhtml_collection_t* collection, myhtml_tree_node_t* scope_node, const char* key, size_t key_len, mystatus_t* status) { if(collection == NULL) { collection = myhtml_collection_create(1024, status); @@ -814,7 +879,7 @@ myhtml_collection_t * myhtml_get_nodes_by_attribute_key(myhtml_tree_t *tree, myh if(scope_node == NULL) scope_node = tree->node_html; - myhtml_status_t rec_status = myhtml_get_nodes_by_attribute_key_recursion(scope_node, collection, key, key_len); + mystatus_t rec_status = myhtml_get_nodes_by_attribute_key_recursion(scope_node, collection, key, key_len); if(rec_status && status) *status = rec_status; @@ -823,28 +888,28 @@ myhtml_collection_t * myhtml_get_nodes_by_attribute_key(myhtml_tree_t *tree, myh } /* find by attribute value; case-sensitivity */ -bool myhtml_get_nodes_by_attribute_value_recursion_eq(myhtml_string_t* str, const char* value, size_t value_len) +bool myhtml_get_nodes_by_attribute_value_recursion_eq(mycore_string_t* str, const char* value, size_t value_len) { - return str->length == value_len && myhtml_strncmp(str->data, value, value_len) == 0; + return str->length == value_len && mycore_strncmp(str->data, value, value_len) == 0; } -bool myhtml_get_nodes_by_attribute_value_recursion_whitespace_separated(myhtml_string_t* str, const char* value, size_t value_len) +bool myhtml_get_nodes_by_attribute_value_recursion_whitespace_separated(mycore_string_t* str, const char* value, size_t value_len) { if(str->length < value_len) return false; const char *data = str->data; - if(myhtml_strncmp(data, value, value_len) == 0) { - if((str->length > value_len && myhtml_utils_whithspace(data[value_len], ==, ||)) || str->length == value_len) + if(mycore_strncmp(data, value, value_len) == 0) { + if((str->length > value_len && mycore_utils_whithspace(data[value_len], ==, ||)) || str->length == value_len) return true; } for(size_t i = 1; (str->length - i) >= value_len; i++) { - if(myhtml_utils_whithspace(data[(i - 1)], ==, ||)) { - if(myhtml_strncmp(&data[i], value, value_len) == 0) { - if((i > value_len && myhtml_utils_whithspace(data[(i + value_len)], ==, ||)) || (str->length - i) == value_len) + if(mycore_utils_whithspace(data[(i - 1)], ==, ||)) { + if(mycore_strncmp(&data[i], value, value_len) == 0) { + if((i > value_len && mycore_utils_whithspace(data[(i + value_len)], ==, ||)) || (str->length - i) == value_len) return true; } } @@ -853,23 +918,23 @@ bool myhtml_get_nodes_by_attribute_value_recursion_whitespace_separated(myhtml_s return false; } -bool myhtml_get_nodes_by_attribute_value_recursion_begin(myhtml_string_t* str, const char* value, size_t value_len) +bool myhtml_get_nodes_by_attribute_value_recursion_begin(mycore_string_t* str, const char* value, size_t value_len) { if(str->length < value_len) return false; - return myhtml_strncmp(str->data, value, value_len) == 0; + return mycore_strncmp(str->data, value, value_len) == 0; } -bool myhtml_get_nodes_by_attribute_value_recursion_end(myhtml_string_t* str, const char* value, size_t value_len) +bool myhtml_get_nodes_by_attribute_value_recursion_end(mycore_string_t* str, const char* value, size_t value_len) { if(str->length < value_len) return false; - return myhtml_strncmp(&str->data[ (str->length - (str->length - value_len)) ], value, value_len) == 0; + return mycore_strncmp(&str->data[ (str->length - (str->length - value_len)) ], value, value_len) == 0; } -bool myhtml_get_nodes_by_attribute_value_recursion_contain(myhtml_string_t* str, const char* value, size_t value_len) +bool myhtml_get_nodes_by_attribute_value_recursion_contain(mycore_string_t* str, const char* value, size_t value_len) { if(str->length < value_len) return false; @@ -878,7 +943,7 @@ bool myhtml_get_nodes_by_attribute_value_recursion_contain(myhtml_string_t* str, for(size_t i = 0; (str->length - i) >= value_len; i++) { - if(myhtml_strncmp(&data[i], value, value_len) == 0) { + if(mycore_strncmp(&data[i], value, value_len) == 0) { return true; } } @@ -886,16 +951,16 @@ bool myhtml_get_nodes_by_attribute_value_recursion_contain(myhtml_string_t* str, return false; } -bool myhtml_get_nodes_by_attribute_value_recursion_hyphen_separated(myhtml_string_t* str, const char* value, size_t value_len) +bool myhtml_get_nodes_by_attribute_value_recursion_hyphen_separated(mycore_string_t* str, const char* value, size_t value_len) { const char *data = str->data; if(str->length < value_len) return false; - else if(str->length == value_len && myhtml_strncmp(data, value, value_len) == 0) { + else if(str->length == value_len && mycore_strncmp(data, value, value_len) == 0) { return true; } - else if(myhtml_strncmp(data, value, value_len) == 0 && data[value_len] == '-') { + else if(mycore_strncmp(data, value, value_len) == 0 && data[value_len] == '-') { return true; } @@ -903,28 +968,28 @@ bool myhtml_get_nodes_by_attribute_value_recursion_hyphen_separated(myhtml_strin } /* find by attribute value; case-insensitive */ -bool myhtml_get_nodes_by_attribute_value_recursion_eq_i(myhtml_string_t* str, const char* value, size_t value_len) +bool myhtml_get_nodes_by_attribute_value_recursion_eq_i(mycore_string_t* str, const char* value, size_t value_len) { - return str->length == value_len && myhtml_strncasecmp(str->data, value, value_len) == 0; + return str->length == value_len && mycore_strncasecmp(str->data, value, value_len) == 0; } -bool myhtml_get_nodes_by_attribute_value_recursion_whitespace_separated_i(myhtml_string_t* str, const char* value, size_t value_len) +bool myhtml_get_nodes_by_attribute_value_recursion_whitespace_separated_i(mycore_string_t* str, const char* value, size_t value_len) { if(str->length < value_len) return false; const char *data = str->data; - if(myhtml_strncasecmp(data, value, value_len) == 0) { - if((str->length > value_len && myhtml_utils_whithspace(data[value_len], ==, ||)) || str->length == value_len) + if(mycore_strncasecmp(data, value, value_len) == 0) { + if((str->length > value_len && mycore_utils_whithspace(data[value_len], ==, ||)) || str->length == value_len) return true; } for(size_t i = 1; (str->length - i) >= value_len; i++) { - if(myhtml_utils_whithspace(data[(i - 1)], ==, ||)) { - if(myhtml_strncasecmp(&data[i], value, value_len) == 0) { - if((i > value_len && myhtml_utils_whithspace(data[(i + value_len)], ==, ||)) || (str->length - i) == value_len) + if(mycore_utils_whithspace(data[(i - 1)], ==, ||)) { + if(mycore_strncasecmp(&data[i], value, value_len) == 0) { + if((i > value_len && mycore_utils_whithspace(data[(i + value_len)], ==, ||)) || (str->length - i) == value_len) return true; } } @@ -933,23 +998,23 @@ bool myhtml_get_nodes_by_attribute_value_recursion_whitespace_separated_i(myhtml return false; } -bool myhtml_get_nodes_by_attribute_value_recursion_begin_i(myhtml_string_t* str, const char* value, size_t value_len) +bool myhtml_get_nodes_by_attribute_value_recursion_begin_i(mycore_string_t* str, const char* value, size_t value_len) { if(str->length < value_len) return false; - return myhtml_strncasecmp(str->data, value, value_len) == 0; + return mycore_strncasecmp(str->data, value, value_len) == 0; } -bool myhtml_get_nodes_by_attribute_value_recursion_end_i(myhtml_string_t* str, const char* value, size_t value_len) +bool myhtml_get_nodes_by_attribute_value_recursion_end_i(mycore_string_t* str, const char* value, size_t value_len) { if(str->length < value_len) return false; - return myhtml_strncasecmp(&str->data[ (str->length - (str->length - value_len)) ], value, value_len) == 0; + return mycore_strncasecmp(&str->data[ (str->length - (str->length - value_len)) ], value, value_len) == 0; } -bool myhtml_get_nodes_by_attribute_value_recursion_contain_i(myhtml_string_t* str, const char* value, size_t value_len) +bool myhtml_get_nodes_by_attribute_value_recursion_contain_i(mycore_string_t* str, const char* value, size_t value_len) { if(str->length < value_len) return false; @@ -958,7 +1023,7 @@ bool myhtml_get_nodes_by_attribute_value_recursion_contain_i(myhtml_string_t* st for(size_t i = 0; (str->length - i) >= value_len; i++) { - if(myhtml_strncasecmp(&data[i], value, value_len) == 0) { + if(mycore_strncasecmp(&data[i], value, value_len) == 0) { return true; } } @@ -966,16 +1031,16 @@ bool myhtml_get_nodes_by_attribute_value_recursion_contain_i(myhtml_string_t* st return false; } -bool myhtml_get_nodes_by_attribute_value_recursion_hyphen_separated_i(myhtml_string_t* str, const char* value, size_t value_len) +bool myhtml_get_nodes_by_attribute_value_recursion_hyphen_separated_i(mycore_string_t* str, const char* value, size_t value_len) { const char *data = str->data; if(str->length < value_len) return false; - else if(str->length == value_len && myhtml_strncasecmp(data, value, value_len) == 0) { + else if(str->length == value_len && mycore_strncasecmp(data, value, value_len) == 0) { return true; } - else if(myhtml_strncasecmp(data, value, value_len) == 0 && data[value_len] == '-') { + else if(mycore_strncasecmp(data, value, value_len) == 0 && data[value_len] == '-') { return true; } @@ -983,7 +1048,7 @@ bool myhtml_get_nodes_by_attribute_value_recursion_hyphen_separated_i(myhtml_str } /* find by attribute value; basic functions */ -myhtml_status_t myhtml_get_nodes_by_attribute_value_recursion(myhtml_tree_node_t* node, myhtml_collection_t* collection, +mystatus_t myhtml_get_nodes_by_attribute_value_recursion(myhtml_tree_node_t* node, myhtml_collection_t* collection, myhtml_attribute_value_find_f func_eq, const char* value, size_t value_len) { @@ -993,14 +1058,14 @@ myhtml_status_t myhtml_get_nodes_by_attribute_value_recursion(myhtml_tree_node_t myhtml_tree_attr_t* attr = node->token->attr_first; while(attr) { - myhtml_string_t* str = &attr->value; + mycore_string_t* str = &attr->value; if(func_eq(str, value, value_len)) { collection->list[ collection->length ] = node; collection->length++; if(collection->length >= collection->size) { - myhtml_status_t status = myhtml_collection_check_size(collection, 1024, 0); + mystatus_t status = myhtml_collection_check_size(collection, 1024, 0); if(status) return status; @@ -1012,7 +1077,7 @@ myhtml_status_t myhtml_get_nodes_by_attribute_value_recursion(myhtml_tree_node_t } if(node->child) { - myhtml_status_t status = myhtml_get_nodes_by_attribute_value_recursion(node->child, collection, func_eq, value, value_len); + mystatus_t status = myhtml_get_nodes_by_attribute_value_recursion(node->child, collection, func_eq, value, value_len); if(status) return status; @@ -1024,7 +1089,7 @@ myhtml_status_t myhtml_get_nodes_by_attribute_value_recursion(myhtml_tree_node_t return MyHTML_STATUS_OK; } -myhtml_status_t myhtml_get_nodes_by_attribute_value_recursion_by_key(myhtml_tree_node_t* node, myhtml_collection_t* collection, +mystatus_t myhtml_get_nodes_by_attribute_value_recursion_by_key(myhtml_tree_node_t* node, myhtml_collection_t* collection, myhtml_attribute_value_find_f func_eq, const char* key, size_t key_len, const char* value, size_t value_len) @@ -1035,17 +1100,17 @@ myhtml_status_t myhtml_get_nodes_by_attribute_value_recursion_by_key(myhtml_tree myhtml_tree_attr_t* attr = node->token->attr_first; while(attr) { - myhtml_string_t* str_key = &attr->key; - myhtml_string_t* str = &attr->value; + mycore_string_t* str_key = &attr->key; + mycore_string_t* str = &attr->value; - if(str_key->length == key_len && myhtml_strncasecmp(str_key->data, key, key_len) == 0) + if(str_key->length == key_len && mycore_strncasecmp(str_key->data, key, key_len) == 0) { if(func_eq(str, value, value_len)) { collection->list[ collection->length ] = node; collection->length++; if(collection->length >= collection->size) { - myhtml_status_t status = myhtml_collection_check_size(collection, 1024, 0); + mystatus_t status = myhtml_collection_check_size(collection, 1024, 0); if(status) return status; @@ -1058,7 +1123,7 @@ myhtml_status_t myhtml_get_nodes_by_attribute_value_recursion_by_key(myhtml_tree } if(node->child) { - myhtml_status_t status = myhtml_get_nodes_by_attribute_value_recursion_by_key(node->child, collection, func_eq, + mystatus_t status = myhtml_get_nodes_by_attribute_value_recursion_by_key(node->child, collection, func_eq, key, key_len, value, value_len); if(status) @@ -1075,7 +1140,7 @@ myhtml_collection_t * _myhtml_get_nodes_by_attribute_value(myhtml_tree_t *tree, myhtml_attribute_value_find_f func_eq, const char* key, size_t key_len, const char* value, size_t value_len, - myhtml_status_t* status) + mystatus_t* status) { if(collection == NULL) { collection = myhtml_collection_create(1024, status); @@ -1087,7 +1152,7 @@ myhtml_collection_t * _myhtml_get_nodes_by_attribute_value(myhtml_tree_t *tree, if(node == NULL) node = tree->node_html; - myhtml_status_t rec_status; + mystatus_t rec_status; if(key && key_len) rec_status = myhtml_get_nodes_by_attribute_value_recursion_by_key(node, collection, func_eq, key, key_len, value, value_len); @@ -1104,7 +1169,7 @@ myhtml_collection_t * myhtml_get_nodes_by_attribute_value(myhtml_tree_t *tree, m bool case_insensitive, const char* key, size_t key_len, const char* value, size_t value_len, - myhtml_status_t* status) + mystatus_t* status) { if(case_insensitive) { return _myhtml_get_nodes_by_attribute_value(tree, collection, node, @@ -1121,7 +1186,7 @@ myhtml_collection_t * myhtml_get_nodes_by_attribute_value_whitespace_separated(m bool case_insensitive, const char* key, size_t key_len, const char* value, size_t value_len, - myhtml_status_t* status) + mystatus_t* status) { if(case_insensitive) { return _myhtml_get_nodes_by_attribute_value(tree, collection, node, @@ -1138,7 +1203,7 @@ myhtml_collection_t * myhtml_get_nodes_by_attribute_value_begin(myhtml_tree_t *t bool case_insensitive, const char* key, size_t key_len, const char* value, size_t value_len, - myhtml_status_t* status) + mystatus_t* status) { if(case_insensitive) { return _myhtml_get_nodes_by_attribute_value(tree, collection, node, @@ -1155,7 +1220,7 @@ myhtml_collection_t * myhtml_get_nodes_by_attribute_value_end(myhtml_tree_t *tre bool case_insensitive, const char* key, size_t key_len, const char* value, size_t value_len, - myhtml_status_t* status) + mystatus_t* status) { if(case_insensitive) { return _myhtml_get_nodes_by_attribute_value(tree, collection, node, @@ -1172,7 +1237,7 @@ myhtml_collection_t * myhtml_get_nodes_by_attribute_value_contain(myhtml_tree_t bool case_insensitive, const char* key, size_t key_len, const char* value, size_t value_len, - myhtml_status_t* status) + mystatus_t* status) { if(case_insensitive) { return _myhtml_get_nodes_by_attribute_value(tree, collection, node, @@ -1189,7 +1254,7 @@ myhtml_collection_t * myhtml_get_nodes_by_attribute_value_hyphen_separated(myhtm bool case_insensitive, const char* key, size_t key_len, const char* value, size_t value_len, - myhtml_status_t* status) + mystatus_t* status) { if(case_insensitive) { return _myhtml_get_nodes_by_attribute_value(tree, collection, node, @@ -1257,7 +1322,7 @@ const char * myhtml_attribute_value(myhtml_tree_attr_t *attr, size_t *length) return NULL; } -myhtml_string_t * myhtml_attribute_key_string(myhtml_tree_attr_t* attr) +mycore_string_t * myhtml_attribute_key_string(myhtml_tree_attr_t* attr) { if(attr) return &attr->key; @@ -1265,7 +1330,7 @@ myhtml_string_t * myhtml_attribute_key_string(myhtml_tree_attr_t* attr) return NULL; } -myhtml_string_t * myhtml_attribute_value_string(myhtml_tree_attr_t* attr) +mycore_string_t * myhtml_attribute_value_string(myhtml_tree_attr_t* attr) { if(attr) return &attr->value; @@ -1281,7 +1346,7 @@ myhtml_tree_attr_t * myhtml_attribute_by_key(myhtml_tree_node_t *node, const cha return myhtml_token_attr_by_name(node->token, key, key_len); } -myhtml_tree_attr_t * myhtml_attribute_add(myhtml_tree_node_t *node, const char *key, size_t key_len, const char *value, size_t value_len, myhtml_encoding_t encoding) +myhtml_tree_attr_t * myhtml_attribute_add(myhtml_tree_node_t *node, const char *key, size_t key_len, const char *value, size_t value_len, myencoding_t encoding) { if(node == NULL) return NULL; @@ -1353,9 +1418,9 @@ myhtml_position_t myhtml_attribute_value_raw_position(myhtml_tree_attr_t *attr) /* * Collections */ -myhtml_collection_t * myhtml_collection_create(size_t size, myhtml_status_t *status) +myhtml_collection_t * myhtml_collection_create(size_t size, mystatus_t *status) { - myhtml_collection_t *collection = (myhtml_collection_t*)myhtml_malloc(sizeof(myhtml_collection_t)); + myhtml_collection_t *collection = (myhtml_collection_t*)mycore_malloc(sizeof(myhtml_collection_t)); if(collection == NULL) { if(status) @@ -1366,10 +1431,10 @@ myhtml_collection_t * myhtml_collection_create(size_t size, myhtml_status_t *sta collection->size = size; collection->length = 0; - collection->list = (myhtml_tree_node_t **)myhtml_malloc(sizeof(myhtml_tree_node_t*) * size); + collection->list = (myhtml_tree_node_t **)mycore_malloc(sizeof(myhtml_tree_node_t*) * size); if(collection->list == NULL) { - myhtml_free(collection); + mycore_free(collection); if(status) *status = MyHTML_STATUS_ERROR_MEMORY_ALLOCATION; @@ -1383,12 +1448,12 @@ myhtml_collection_t * myhtml_collection_create(size_t size, myhtml_status_t *sta return collection; } -myhtml_status_t myhtml_collection_check_size(myhtml_collection_t *collection, size_t need, size_t upto_length) +mystatus_t myhtml_collection_check_size(myhtml_collection_t *collection, size_t need, size_t upto_length) { if((collection->length + need) >= collection->size) { size_t tmp_size = collection->length + need + upto_length + 1; - myhtml_tree_node_t **tmp = (myhtml_tree_node_t **)myhtml_realloc(collection->list, sizeof(myhtml_tree_node_t*) * tmp_size); + myhtml_tree_node_t **tmp = (myhtml_tree_node_t **)mycore_realloc(collection->list, sizeof(myhtml_tree_node_t*) * tmp_size); if(tmp) { collection->size = tmp_size; @@ -1413,15 +1478,15 @@ myhtml_collection_t * myhtml_collection_destroy(myhtml_collection_t *collection) return NULL; if(collection->list) - myhtml_free(collection->list); + mycore_free(collection->list); - myhtml_free(collection); + mycore_free(collection); return NULL; } /* queue */ -myhtml_status_t myhtml_queue_add(myhtml_tree_t *tree, size_t begin, myhtml_token_node_t* token) +mystatus_t myhtml_queue_add(myhtml_tree_t *tree, size_t begin, myhtml_token_node_t* token) { // TODO: need refactoring this code // too many conditions @@ -1437,50 +1502,48 @@ myhtml_status_t myhtml_queue_add(myhtml_tree_t *tree, size_t begin, myhtml_token } } -#ifndef MyHTML_BUILD_WITHOUT_THREADS +#ifndef MyCORE_BUILD_WITHOUT_THREADS if(tree->flags & MyHTML_TREE_FLAGS_SINGLE_MODE) { if(qnode && token) { - qnode->token = token; + qnode->args = token; myhtml_parser_worker(0, qnode); myhtml_parser_stream(0, qnode); } - tree->current_qnode = mythread_queue_node_malloc_limit(tree->myhtml->thread, tree->queue, 4, NULL); + tree->current_qnode = mythread_queue_node_malloc_limit(tree->myhtml->thread_stream, tree->queue, 4, NULL); } else { if(qnode) - qnode->token = token; + qnode->args = token; - tree->current_qnode = mythread_queue_node_malloc_round(tree->myhtml->thread, tree->queue_entry, NULL); + tree->current_qnode = mythread_queue_node_malloc_round(tree->myhtml->thread_stream, tree->queue_entry, NULL); } #else if(qnode && token) { - qnode->token = token; + qnode->args = token; myhtml_parser_worker(0, qnode); myhtml_parser_stream(0, qnode); } - tree->current_qnode = mythread_queue_node_malloc_limit(tree->myhtml->thread, tree->queue, 4, NULL); + tree->current_qnode = mythread_queue_node_malloc_limit(tree->myhtml->thread_stream, tree->queue, 4, NULL); -#endif /* MyHTML_BUILD_WITHOUT_THREADS */ +#endif /* MyCORE_BUILD_WITHOUT_THREADS */ - if(tree->current_qnode == NULL) { + if(tree->current_qnode == NULL) return MyHTML_STATUS_ERROR_MEMORY_ALLOCATION; - } - tree->current_qnode->tree = tree; + tree->current_qnode->context = tree; tree->current_qnode->prev = qnode; if(qnode && token) myhtml_tokenizer_calc_current_namespace(tree, token); tree->current_token_node = myhtml_token_node_create(tree->token, tree->token->mcasync_token_id); - if(tree->current_token_node == NULL) return MyHTML_STATUS_ERROR_MEMORY_ALLOCATION; |