myhtml_t* myhtml_destroy(myhtml_t* myhtml) { if(myhtml == NULL) return NULL; myhtml_destroy_marker(myhtml); #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_stream = mythread_destroy(myhtml->thread_stream, mythread_callback_quit, NULL, true); 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) mycore_free(myhtml->insertion_func); mycore_free(myhtml); return NULL; }
mystatus_t myhtml_batch_create(myhtml_t* myhtml, mystatus_t* status, size_t count, size_t id_increase) { if(count == 0) { myhtml->thread_batch = NULL; *status = MyHTML_STATUS_OK; return *status; } 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 = 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; } /* 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; }
myhtml_t* myhtml_destroy(myhtml_t* myhtml) { if(myhtml == NULL) return NULL; myhtml_destroy_marker(myhtml); mythread_destroy(myhtml->thread, true); myhtml_tokenizer_state_destroy(myhtml); if(myhtml->insertion_func) myhtml_free(myhtml->insertion_func); myhtml_free(myhtml); return NULL; }
myhtml_t* myhtml_destroy(myhtml_t* myhtml) { if(myhtml == NULL) return NULL; mythread_destroy(myhtml->thread, mytrue); myhtml_tokenizer_state_destroy(myhtml); myhtml->async_incoming_buf = mcobject_async_destroy(myhtml->async_incoming_buf, mytrue); myhtml->tags = myhtml_tag_destroy(myhtml->tags); if(myhtml->insertion_func) free(myhtml->insertion_func); free(myhtml); return NULL; }
myhtml_t* myhtml_destroy(myhtml_t* myhtml) { if(myhtml == NULL) return NULL; myhtml_destroy_marker(myhtml); mythread_destroy(myhtml->thread, true); myhtml_tokenizer_state_destroy(myhtml); myhtml->async_incoming_buf = mcobject_async_destroy(myhtml->async_incoming_buf, true); myhtml->tag_index = mcobject_async_destroy(myhtml->tag_index, true); myhtml->mchar = mchar_async_destroy(myhtml->mchar, true); if(myhtml->insertion_func) free(myhtml->insertion_func); free(myhtml); return NULL; }