Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/lexborisov/Modest.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/myhtml/utils')
-rw-r--r--source/myhtml/utils/avl_tree.c353
-rw-r--r--source/myhtml/utils/avl_tree.h68
-rw-r--r--source/myhtml/utils/mchar_async.c770
-rw-r--r--source/myhtml/utils/mchar_async.h131
-rw-r--r--source/myhtml/utils/mcobject.c194
-rw-r--r--source/myhtml/utils/mcobject.h70
-rw-r--r--source/myhtml/utils/mcobject_async.c475
-rw-r--r--source/myhtml/utils/mcobject_async.h114
-rw-r--r--source/myhtml/utils/mcsimple.c125
-rw-r--r--source/myhtml/utils/mcsimple.h61
-rw-r--r--source/myhtml/utils/mcsync.c155
-rw-r--r--source/myhtml/utils/mcsync.h81
-rw-r--r--source/myhtml/utils/mctree.c285
-rw-r--r--source/myhtml/utils/mctree.h97
-rw-r--r--source/myhtml/utils/mhash.c267
-rw-r--r--source/myhtml/utils/mhash.h65
-rw-r--r--source/myhtml/utils/resources.h217
17 files changed, 0 insertions, 3528 deletions
diff --git a/source/myhtml/utils/avl_tree.c b/source/myhtml/utils/avl_tree.c
deleted file mode 100644
index b8da055..0000000
--- a/source/myhtml/utils/avl_tree.c
+++ /dev/null
@@ -1,353 +0,0 @@
-/*
- Copyright (C) 2016 Alexander Borisov
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin avl_treet, Fifth Floor, Boston, MA 02110-1301 USA
-
- Author: lex.borisov@gmail.com (Alexander Borisov)
-*/
-
-#include "myhtml/utils/avl_tree.h"
-
-myhtml_utils_avl_tree_t * myhtml_utils_avl_tree_create(void)
-{
- return (myhtml_utils_avl_tree_t*)myhtml_calloc(1, sizeof(myhtml_utils_avl_tree_t));
-}
-
-myhtml_status_t myhtml_utils_avl_tree_init(myhtml_utils_avl_tree_t* avl_tree)
-{
- /* for raw declaration style */
- avl_tree->mc_nodes = mcobject_create();
- if(avl_tree->mc_nodes == NULL)
- return MyHTML_STATUS_ERROR_MEMORY_ALLOCATION;
-
- myhtml_status_t myhtml_status = mcobject_init(avl_tree->mc_nodes, 256, sizeof(myhtml_utils_avl_tree_node_t));
- if(myhtml_status)
- return MyHTML_STATUS_ERROR;
-
- return MyHTML_STATUS_OK;
-}
-
-void myhtml_utils_avl_tree_clean(myhtml_utils_avl_tree_t* avl_tree)
-{
- mcobject_clean(avl_tree->mc_nodes);
-}
-
-myhtml_utils_avl_tree_t * myhtml_utils_avl_tree_destroy(myhtml_utils_avl_tree_t* avl_tree, bool self_destroy)
-{
- if(avl_tree == NULL)
- return NULL;
-
- mcobject_destroy(avl_tree->mc_nodes, true);
-
- if(self_destroy) {
- myhtml_free(avl_tree);
- return NULL;
- }
-
- return avl_tree;
-}
-
-myhtml_utils_avl_tree_node_t * myhtml_utils_avl_tree_node_create_root(myhtml_utils_avl_tree_t* avl_tree, size_t type, void* value)
-{
- myhtml_utils_avl_tree_node_t *node = mcobject_malloc(avl_tree->mc_nodes, NULL);
- memset(node, 0, sizeof(myhtml_utils_avl_tree_node_t));
-
- node->type = type;
- node->value = value;
-
- return node;
-}
-
-void myhtml_utils_avl_tree_node_clean(myhtml_utils_avl_tree_node_t* node)
-{
- memset(node, 0, sizeof(myhtml_utils_avl_tree_node_t));
-}
-
-short myhtml_utils_avl_tree_node_height(myhtml_utils_avl_tree_node_t* node)
-{
- return (node ? node->height : 0);
-}
-
-short myhtml_utils_avl_tree_node_balance_factor(myhtml_utils_avl_tree_node_t* node)
-{
- return (myhtml_utils_avl_tree_node_height(node->right) - myhtml_utils_avl_tree_node_height(node->left));
-}
-
-void myhtml_utils_avl_tree_node_set_height(myhtml_utils_avl_tree_node_t* node)
-{
- short left_height = myhtml_utils_avl_tree_node_height(node->left);
- short right_height = myhtml_utils_avl_tree_node_height(node->right);
-
- node->height = (left_height > right_height ? left_height : right_height) + 1;
-}
-
-myhtml_utils_avl_tree_node_t * myhtml_utils_avl_tree_node_rotate_right(myhtml_utils_avl_tree_node_t* pos)
-{
- myhtml_utils_avl_tree_node_t* node = pos->left;
-
- node->parent = pos->parent;
-
- if(node->right)
- node->right->parent = pos;
-
- pos->left = node->right;
- pos->parent = node;
-
- node->right = pos;
-
- myhtml_utils_avl_tree_node_set_height(pos);
- myhtml_utils_avl_tree_node_set_height(node);
-
- return node;
-}
-
-myhtml_utils_avl_tree_node_t * myhtml_utils_avl_tree_node_rotate_left(myhtml_utils_avl_tree_node_t* pos)
-{
- myhtml_utils_avl_tree_node_t* node = pos->right;
-
- node->parent = pos->parent;
-
- if(node->left)
- node->left->parent = pos;
-
- pos->right = node->left;
- pos->parent = node;
-
- node->left = pos;
-
- myhtml_utils_avl_tree_node_set_height(pos);
- myhtml_utils_avl_tree_node_set_height(node);
-
- return node;
-}
-
-myhtml_utils_avl_tree_node_t * myhtml_utils_avl_tree_node_balance(myhtml_utils_avl_tree_node_t* node, myhtml_utils_avl_tree_node_t** root)
-{
- /* set height */
- short left_height = myhtml_utils_avl_tree_node_height(node->left);
- short right_height = myhtml_utils_avl_tree_node_height(node->right);
-
- node->height = (left_height > right_height ? left_height : right_height) + 1;
-
- /* check balance */
- switch ((right_height - left_height))
- {
- case 2: {
- if(myhtml_utils_avl_tree_node_balance_factor(node->right) < 0)
- node->right = myhtml_utils_avl_tree_node_rotate_right(node->right);
-
- myhtml_utils_avl_tree_node_t* parent = node->parent;
-
- if(parent) {
- if(parent->right == node)
- return parent->right = myhtml_utils_avl_tree_node_rotate_left(node);
- else
- return parent->left = myhtml_utils_avl_tree_node_rotate_left(node);
- }
-
- return myhtml_utils_avl_tree_node_rotate_left(node);
- }
- case -2: {
- if(myhtml_utils_avl_tree_node_balance_factor(node->left) > 0)
- node->left = myhtml_utils_avl_tree_node_rotate_left(node->left);
-
- myhtml_utils_avl_tree_node_t* parent = node->parent;
-
- if(parent) {
- if(parent->right == node)
- return parent->right = myhtml_utils_avl_tree_node_rotate_right(node);
- else
- return parent->left = myhtml_utils_avl_tree_node_rotate_right(node);
- }
-
- return myhtml_utils_avl_tree_node_rotate_right(node);
- }
- default:
- break;
- }
-
- if(node->parent == NULL)
- *root = node;
-
- return node->parent;
-}
-
-void myhtml_utils_avl_tree_add(myhtml_utils_avl_tree_t* avl_tree, myhtml_utils_avl_tree_node_t** root, size_t type, void* value)
-{
- if(*root == NULL) {
- *root = myhtml_utils_avl_tree_node_create_root(avl_tree, type, value);
- return;
- }
-
- myhtml_utils_avl_tree_node_t* node = *root;
- myhtml_utils_avl_tree_node_t* new_node = mcobject_malloc(avl_tree->mc_nodes, NULL);
- myhtml_utils_avl_tree_node_clean(new_node);
-
- while(1)
- {
- if(type == node->type) {
- node->value = value;
- return;
- }
- else if(type < node->type) {
- if(node->left == NULL) {
- node->left = new_node;
-
- new_node->parent = node;
- new_node->type = type;
- new_node->value = value;
-
- node = new_node;
- break;
- }
-
- node = node->left;
- }
- else {
- if(node->right == NULL) {
- node->right = new_node;
-
- new_node->parent = node;
- new_node->type = type;
- new_node->value = value;
-
- node = new_node;
- break;
- }
-
- node = node->right;
- }
- }
-
- while(node) {
- node = myhtml_utils_avl_tree_node_balance(node, root);
- }
-}
-
-myhtml_utils_avl_tree_node_t * myhtml_utils_avl_tree_find_min(myhtml_utils_avl_tree_node_t* node)
-{
- if(node == NULL)
- return NULL;
-
- while(node->right) {
- node = node->right;
- }
-
- return node;
-}
-
-void myhtml_utils_avl_tree_rotate_for_delete(myhtml_utils_avl_tree_node_t* delete_node, myhtml_utils_avl_tree_node_t* node, myhtml_utils_avl_tree_node_t** root)
-{
- myhtml_utils_avl_tree_node_t* balance_node;
-
- if(node) {
- if(delete_node->left == node) {
- balance_node = node->left ? node->left : node;
-
- node->parent = delete_node->parent;
- node->right = delete_node->right;
-
- if(delete_node->right)
- delete_node->right->parent = node;
- }
- else {
- balance_node = node;
-
- node->parent->right = NULL;
- node->parent = delete_node->parent;
- node->right = delete_node->right;
- node->left = delete_node->left;
-
- if(delete_node->left)
- delete_node->left->parent = node;
- if(delete_node->right)
- delete_node->right->parent = node;
- }
-
- if(delete_node->parent) {
- if(delete_node->parent->left == delete_node) { delete_node->parent->left = node; }
- else { delete_node->parent->right = node; }
- }
- else {
- *root = node;
- }
- }
- else {
- balance_node = delete_node->parent;
-
- if(delete_node->parent) {
- if(delete_node->parent->left == delete_node) { delete_node->parent->left = delete_node->right; }
- else { delete_node->parent->right = delete_node->right; }
- }
- else {
- *root = delete_node->right;
- }
- }
-
- while(balance_node) {
- balance_node = myhtml_utils_avl_tree_node_balance(balance_node, root);
- }
-}
-
-void * myhtml_utils_avl_tree_delete(myhtml_utils_avl_tree_t *avl_tree, myhtml_utils_avl_tree_node_t** root, size_t type)
-{
- myhtml_utils_avl_tree_node_t* node = *root;
-
- while(node)
- {
- if(type == node->type) {
- myhtml_utils_avl_tree_rotate_for_delete(node, myhtml_utils_avl_tree_find_min(node->left), root);
-
- void *value = node->value;
- mcobject_free(avl_tree->mc_nodes, node);
-
- return value;
- }
- else if(type < node->type)
- node = node->left;
- else
- node = node->right;
- }
-
- return NULL;
-}
-
-myhtml_utils_avl_tree_node_t * myhtml_utils_avl_tree_search_by_type(myhtml_utils_avl_tree_t *avl_tree, myhtml_utils_avl_tree_node_t* node, size_t type)
-{
- while(node)
- {
- if(type == node->type)
- return node;
- else if(type < node->type)
- node = node->left;
- else
- node = node->right;
- }
-
- return NULL;
-}
-
-void myhtml_utils_avl_tree_list_all_nodes(myhtml_utils_avl_tree_t *avl_tree, myhtml_utils_avl_tree_node_t* root, myhtml_utils_avl_tree_node_callback_f callback, void* ctx)
-{
- if(root == NULL)
- return;
-
- callback(root, ctx);
-
- myhtml_utils_avl_tree_list_all_nodes(avl_tree, root->left, callback, ctx);
- myhtml_utils_avl_tree_list_all_nodes(avl_tree, root->right, callback, ctx);
-}
-
-
diff --git a/source/myhtml/utils/avl_tree.h b/source/myhtml/utils/avl_tree.h
deleted file mode 100644
index f2c837e..0000000
--- a/source/myhtml/utils/avl_tree.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- Copyright (C) 2016 Alexander Borisov
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin avl_treet, Fifth Floor, Boston, MA 02110-1301 USA
-
- Author: lex.borisov@gmail.com (Alexander Borisov)
-*/
-
-#ifndef MyHTML_UTILS_AVL_TREE_H
-#define MyHTML_UTILS_AVL_TREE_H
-#pragma once
-
-#include "myhtml/myosi.h"
-#include "myhtml/utils/mcobject.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct myhtml_utils_avl_tree_node myhtml_utils_avl_tree_node_t;
-typedef void (*myhtml_utils_avl_tree_node_callback_f)(myhtml_utils_avl_tree_node_t* avl_tree_node, void* ctx);
-
-struct myhtml_utils_avl_tree_node {
- void *value;
- size_t type;
-
- myhtml_utils_avl_tree_node_t* left;
- myhtml_utils_avl_tree_node_t* right;
- myhtml_utils_avl_tree_node_t* parent;
-
- short height;
-};
-
-struct myhtml_utils_avl_tree {
- mcobject_t* mc_nodes;
-}
-typedef myhtml_utils_avl_tree_t;
-
-myhtml_utils_avl_tree_t * myhtml_utils_avl_tree_create(void);
-myhtml_status_t myhtml_utils_avl_tree_init(myhtml_utils_avl_tree_t* avl_tree);
-void myhtml_utils_avl_tree_clean(myhtml_utils_avl_tree_t* avl_tree);
-myhtml_utils_avl_tree_t * myhtml_utils_avl_tree_destroy(myhtml_utils_avl_tree_t* avl_tree, bool self_destroy);
-
-myhtml_utils_avl_tree_node_t * myhtml_utils_avl_tree_node_create_root(myhtml_utils_avl_tree_t* avl_tree, size_t type, void* value);
-
-void myhtml_utils_avl_tree_add(myhtml_utils_avl_tree_t* avl_tree, myhtml_utils_avl_tree_node_t** root, size_t type, void* value);
-void * myhtml_utils_avl_tree_delete(myhtml_utils_avl_tree_t *avl_tree, myhtml_utils_avl_tree_node_t** root, size_t type);
-myhtml_utils_avl_tree_node_t * myhtml_utils_avl_tree_search_by_type(myhtml_utils_avl_tree_t *avl_tree, myhtml_utils_avl_tree_node_t* node, size_t type);
-
-void myhtml_utils_avl_tree_list_all_nodes(myhtml_utils_avl_tree_t *avl_tree, myhtml_utils_avl_tree_node_t* root, myhtml_utils_avl_tree_node_callback_f callback, void* ctx);
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-#endif /* MyHTML_UTILS_AVL_TREE_H */
diff --git a/source/myhtml/utils/mchar_async.c b/source/myhtml/utils/mchar_async.c
deleted file mode 100644
index 37c8c57..0000000
--- a/source/myhtml/utils/mchar_async.c
+++ /dev/null
@@ -1,770 +0,0 @@
-/*
- Copyright (C) 2015-2016 Alexander Borisov
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
- Author: lex.borisov@gmail.com (Alexander Borisov)
-*/
-
-#include "myhtml/utils/mchar_async.h"
-
-mchar_async_t * mchar_async_create(size_t pos_size, size_t size)
-{
- mchar_async_t *mcobj_async = (mchar_async_t*)myhtml_calloc(1, sizeof(mchar_async_t));
-
- mchar_async_init(mcobj_async, pos_size, size);
-
- return mcobj_async;
-}
-
-void mchar_async_init(mchar_async_t *mchar_async, size_t chunk_len, size_t char_size)
-{
- if(char_size < 4096)
- char_size = 4096;
-
- mchar_async->origin_size = char_size;
-
- mchar_async->chunks_size = chunk_len;
- mchar_async->chunks_pos_size = 1024;
- mchar_async->chunks = (mchar_async_chunk_t**)myhtml_calloc(mchar_async->chunks_pos_size, sizeof(mchar_async_chunk_t*));
- mchar_async->chunks[0] = (mchar_async_chunk_t*)myhtml_calloc(mchar_async->chunks_size, sizeof(mchar_async_chunk_t));
-
- mchar_async_cache_init(&mchar_async->chunk_cache);
-
- mchar_async->nodes_length = 0;
- mchar_async->nodes_size = 64;
- mchar_async->nodes = (mchar_async_node_t*)myhtml_calloc(mchar_async->nodes_size, sizeof(mchar_async_node_t));
-
- mchar_async->nodes_cache_length = 0;
- mchar_async->nodes_cache_size = mchar_async->nodes_size;
- mchar_async->nodes_cache = (size_t*)myhtml_malloc(mchar_async->nodes_cache_size * sizeof(size_t));
-
- mchar_async_clean(mchar_async);
-
- mchar_async->mcsync = mcsync_create();
-}
-
-void mchar_async_clean(mchar_async_t *mchar_async)
-{
- mchar_async->chunks_length = 0;
- mchar_async->chunks_pos_length = 1;
-
- mchar_async_cache_clean(&mchar_async->chunk_cache);
-
- for (size_t node_idx = 0; node_idx < mchar_async->nodes_length; node_idx++)
- {
- mchar_async_node_t *node = &mchar_async->nodes[node_idx];
- mchar_async_cache_clean(&node->cache);
-
- node->chunk = mchar_async_chunk_malloc(mchar_async, node, mchar_async->origin_size);
- node->chunk->prev = 0;
- }
-}
-
-mchar_async_t * mchar_async_destroy(mchar_async_t *mchar_async, int destroy_self)
-{
- if(mchar_async == NULL)
- return NULL;
-
- if(mchar_async->nodes)
- {
- for (size_t node_idx = 0; node_idx < mchar_async->nodes_length; node_idx++)
- {
- mchar_async_node_t *node = &mchar_async->nodes[node_idx];
- mchar_async_cache_destroy(&node->cache, false);
- }
-
- myhtml_free(mchar_async->nodes);
- mchar_async->nodes = NULL;
- }
-
- if(mchar_async->nodes_cache) {
- myhtml_free(mchar_async->nodes_cache);
- }
-
- if(mchar_async->chunks)
- {
- for (size_t pos_idx = 0; pos_idx < mchar_async->chunks_pos_length; pos_idx++) {
- if(mchar_async->chunks[pos_idx])
- {
- for (size_t idx = 0; idx < mchar_async->chunks_size; idx++) {
- if(mchar_async->chunks[pos_idx][idx].begin)
- myhtml_free(mchar_async->chunks[pos_idx][idx].begin);
- }
-
- myhtml_free(mchar_async->chunks[pos_idx]);
- }
- }
-
- myhtml_free(mchar_async->chunks);
- mchar_async->chunks = NULL;
- }
-
- mchar_async_cache_destroy(&mchar_async->chunk_cache, false);
-
- mchar_async->mcsync = mcsync_destroy(mchar_async->mcsync, 1);
-
- memset(mchar_async, 0, sizeof(mchar_async_t));
-
- if(destroy_self)
- myhtml_free(mchar_async);
- else
- return mchar_async;
-
- return NULL;
-}
-
-void mchar_async_mem_malloc(mchar_async_t *mchar_async, mchar_async_node_t *node, mchar_async_chunk_t *chunk, size_t length)
-{
- if(chunk == NULL)
- return;
-
- if(chunk->begin) {
- if(length > chunk->size) {
- myhtml_free(chunk->begin);
-
- chunk->size = length + mchar_async->origin_size;
- chunk->begin = (char*)myhtml_malloc(chunk->size * sizeof(char));
- }
- }
- else {
- chunk->size = mchar_async->origin_size;
-
- if(length > chunk->size)
- chunk->size = length;
-
- chunk->begin = (char*)myhtml_malloc(chunk->size * sizeof(char));
- }
-
- chunk->length = 0;
-}
-
-mchar_async_chunk_t * mchar_async_chunk_malloc_without_lock(mchar_async_t *mchar_async, mchar_async_node_t *node, size_t length)
-{
- if(mchar_async_cache_has_nodes(mchar_async->chunk_cache))
- {
- size_t index = mchar_async_cache_delete(&mchar_async->chunk_cache, length);
-
- if(index)
- return (mchar_async_chunk_t*)mchar_async->chunk_cache.nodes[index].value;
- }
-
- if(mchar_async->chunks_length >= mchar_async->chunks_size)
- {
- size_t current_idx = mchar_async->chunks_pos_length;
- mchar_async->chunks_pos_length++;
-
- if(mchar_async->chunks_pos_length >= mchar_async->chunks_pos_size)
- {
- mchar_async->chunks_pos_size <<= 1;
- mchar_async_chunk_t **tmp_pos = myhtml_realloc(mchar_async->chunks,
- sizeof(mchar_async_chunk_t*) * mchar_async->chunks_pos_size);
-
- if(tmp_pos) {
- memset(&tmp_pos[mchar_async->chunks_pos_length], 0, (mchar_async->chunks_pos_size - mchar_async->chunks_pos_length)
- * sizeof(mchar_async_chunk_t*));
-
- mchar_async->chunks = tmp_pos;
- }
- }
-
- if(mchar_async->chunks[current_idx] == NULL) {
- mchar_async_chunk_t *tmp = myhtml_calloc(mchar_async->chunks_size, sizeof(mchar_async_chunk_t));
-
- if(tmp)
- mchar_async->chunks[current_idx] = tmp;
- }
-
- mchar_async->chunks_length = 0;
- }
-
- mchar_async_chunk_t *chunk = &mchar_async->chunks[mchar_async->chunks_pos_length - 1][mchar_async->chunks_length];
- mchar_async->chunks_length++;
-
- mchar_async_mem_malloc(mchar_async, node, chunk, length);
-
- return chunk;
-}
-
-mchar_async_chunk_t * mchar_async_chunk_malloc(mchar_async_t *mchar_async, mchar_async_node_t *node, size_t length)
-{
- mcsync_lock(mchar_async->mcsync);
- mchar_async_chunk_t *chunk = mchar_async_chunk_malloc_without_lock(mchar_async, node, length);
- mcsync_unlock(mchar_async->mcsync);
-
- return chunk;
-}
-
-size_t mchar_async_node_add(mchar_async_t *mchar_async)
-{
- mcsync_lock(mchar_async->mcsync);
-
- size_t node_idx;
-
- if(mchar_async->nodes_cache_length) {
- mchar_async->nodes_cache_length--;
-
- node_idx = mchar_async->nodes_cache[ mchar_async->nodes_cache_length ];
- }
- else {
- if(mchar_async->nodes_length >= mchar_async->nodes_size) {
- mcsync_unlock(mchar_async->mcsync);
- return 0;
- }
-
- node_idx = mchar_async->nodes_length;
- mchar_async->nodes_length++;
- }
-
- mchar_async_node_t *node = &mchar_async->nodes[node_idx];
-
- mchar_async_cache_init(&node->cache);
-
- node->chunk = mchar_async_chunk_malloc_without_lock(mchar_async, node, mchar_async->origin_size);
-
- node->chunk->next = NULL;
- node->chunk->prev = NULL;
-
- mcsync_unlock(mchar_async->mcsync);
-
- return node_idx;
-}
-
-void mchar_async_node_clean(mchar_async_t *mchar_async, size_t node_idx)
-{
- if(mchar_async->nodes_length <= node_idx)
- return;
-
- mchar_async_node_t *node = &mchar_async->nodes[node_idx];
-
- while (node->chunk->prev)
- node->chunk = node->chunk->prev;
-
- node->chunk->length = 0;
- mchar_async_cache_clean(&node->cache);
-}
-
-void mchar_async_node_delete(mchar_async_t *mchar_async, size_t node_idx)
-{
- mcsync_lock(mchar_async->mcsync);
-
- if(mchar_async->nodes_length <= node_idx) {
- mcsync_unlock(mchar_async->mcsync);
- return;
- }
-
- mchar_async_node_t *node = &mchar_async->nodes[node_idx];
- mchar_async_chunk_t *chunk = node->chunk;
-
- while (chunk->next)
- chunk = chunk->next;
-
- while (chunk)
- {
- mchar_async_cache_add(&mchar_async->chunk_cache, (void*)chunk, chunk->size);
- chunk = chunk->prev;
- }
-
- if(node->cache.nodes)
- mchar_async_cache_destroy(&node->cache, false);
-
- memset(node, 0, sizeof(mchar_async_node_t));
-
- if(mchar_async->nodes_cache_length >= mchar_async->nodes_cache_size) {
- size_t new_size = mchar_async->nodes_cache_size << 1;
-
- size_t *tmp = (size_t*)myhtml_realloc(mchar_async->nodes_cache, sizeof(size_t) * mchar_async->nodes_cache_size);
-
- if(tmp) {
- mchar_async->nodes_cache = tmp;
- mchar_async->nodes_cache_size = new_size;
- }
- }
-
- mchar_async->nodes_cache[ mchar_async->nodes_cache_length ] = node_idx;
- mchar_async->nodes_cache_length++;
-
- mcsync_unlock(mchar_async->mcsync);
-}
-
-mchar_async_chunk_t * mchar_sync_chunk_find_by_size(mchar_async_node_t *node, size_t size)
-{
- mchar_async_chunk_t *chunk = node->chunk->next;
-
- while (chunk) {
- if(chunk->size >= size)
- return chunk;
-
- chunk = chunk->next;
- }
-
- return NULL;
-}
-
-void mchar_sync_chunk_insert_after(mchar_async_chunk_t *base, mchar_async_chunk_t *chunk)
-{
- if(base->next == chunk)
- return;
-
- if(chunk->prev)
- chunk->prev->next = chunk->next;
-
- if(chunk->next)
- chunk->next->prev = chunk->prev;
-
- if(base->next)
- base->next->prev = chunk;
-
- chunk->next = base->next;
- chunk->prev = base;
-
- base->next = chunk;
-}
-
-char * mchar_async_malloc(mchar_async_t *mchar_async, size_t node_idx, size_t size)
-{
- if(size == 0)
- return NULL;
-
- mchar_async_node_t *node = &mchar_async->nodes[node_idx];
- mchar_async_chunk_t *chunk = node->chunk;
-
- if(mchar_async_cache_has_nodes(node->cache)) {
- size_t index = mchar_async_cache_delete(&node->cache, size);
-
- if(index) {
- return (char *)(node->cache.nodes[index].value);
- }
- }
-
- size_t new_size = chunk->length + size + sizeof(size_t);
-
- if(new_size > chunk->size)
- {
- if((chunk->length + sizeof(size_t)) < chunk->size)
- {
- size_t calc_size = (chunk->size - chunk->length) - sizeof(size_t);
-
- if(calc_size) {
- char *tmp = &chunk->begin[(chunk->length + sizeof(size_t))];
- *(size_t*)(&chunk->begin[chunk->length]) = calc_size;
-
- chunk->length = chunk->size;
-
- mchar_async_cache_add(&node->cache, tmp, calc_size);
- }
- }
-
- chunk = mchar_sync_chunk_find_by_size(node, (size + sizeof(size_t)));
-
- if(chunk)
- chunk->length = 0;
- else {
- if((size + sizeof(size_t)) > mchar_async->origin_size)
- chunk = mchar_async_chunk_malloc(mchar_async, node, (size + sizeof(size_t) + mchar_async->origin_size));
- else
- chunk = mchar_async_chunk_malloc(mchar_async, node, mchar_async->origin_size);
- }
-
- mchar_sync_chunk_insert_after(node->chunk, chunk);
- node->chunk = chunk;
- }
-
- char *tmp = &chunk->begin[(chunk->length + sizeof(size_t))];
- *((size_t*)(&chunk->begin[chunk->length])) = size;
-
- chunk->length = chunk->length + size + sizeof(size_t);
-
- return tmp;
-}
-
-char * mchar_async_realloc(mchar_async_t *mchar_async, size_t node_idx, char *data, size_t data_len, size_t new_size)
-{
- if(data == NULL)
- return NULL;
-
- size_t curr_size = *((size_t*)(data - sizeof(size_t)));
-
- if(curr_size >= new_size)
- return data;
-
- mchar_async_node_t *node = &mchar_async->nodes[node_idx];
-
- if(node->chunk->length >= curr_size &&
- &node->chunk->begin[ (node->chunk->length - curr_size) ] == data)
- {
- size_t next_size = (node->chunk->length - curr_size) + new_size;
-
- if(next_size <= node->chunk->size) {
- /* it`s Magic */
- *((size_t*)(&node->chunk->begin[ ((node->chunk->length - curr_size) - sizeof(size_t)) ])) = new_size;
-
- node->chunk->length = next_size;
-
- return data;
- }
-// else {
-// size_t re_size = next_size - node->chunk->length;
-//
-// /* a little Magic ;) */
-// *((size_t*)(&node->chunk->begin[ ((node->chunk->length - curr_size) - sizeof(size_t)) ])) = re_size;
-//
-// curr_size = re_size;
-// }
- }
-
- char *tmp = mchar_async_malloc(mchar_async, node_idx, new_size);
-
- if(tmp) {
- memcpy(tmp, data, sizeof(char) * data_len);
-
- mchar_async_cache_add(&node->cache, data, curr_size);
- }
-
- return tmp;
-}
-
-char * mchar_async_crop_first_chars(mchar_async_t *mchar_async, size_t node_idx, char *data, size_t crop_len)
-{
- if(data == NULL)
- return NULL;
-
- size_t curr_size = *((size_t*)(data - sizeof(size_t)));
-
- char *tmp_old = data;
- data = &data[crop_len];
-
- *((size_t*)(data - sizeof(size_t))) = curr_size - crop_len;
-
- if((crop_len + 4) > sizeof(size_t)) {
- crop_len = crop_len - sizeof(size_t);
- *((size_t*)(tmp_old - sizeof(size_t))) = crop_len;
-
- mchar_async_node_t *node = &mchar_async->nodes[node_idx];
- mchar_async_cache_add(&node->cache, tmp_old, crop_len);
- }
-
- return data;
-}
-
-char * mchar_async_crop_first_chars_without_cache(char *data, size_t crop_len)
-{
- if(data == NULL)
- return NULL;
-
- size_t curr_size = *((size_t*)(data - sizeof(size_t)));
- data = &data[crop_len];
-
- *((size_t*)(data - sizeof(size_t))) = curr_size - crop_len;
-
- return data;
-}
-
-size_t mchar_async_get_size_by_data(const char *data)
-{
- if(data == NULL)
- return 0;
-
- return *((size_t*)(data - sizeof(size_t)));
-}
-
-void mchar_async_free(mchar_async_t *mchar_async, size_t node_idx, char *entry)
-{
- if(entry)
- mchar_async_cache_add(&mchar_async->nodes[node_idx].cache, entry, *(size_t*)(entry - sizeof(size_t)));
-}
-
-void mchar_async_cache_init(mchar_async_cache_t *cache)
-{
- cache->count = 0;
- cache->nodes_root = 0;
- cache->nodes_length = 1;
- cache->nodes_size = 1024;
- cache->nodes = (mchar_async_cache_node_t*)myhtml_malloc(sizeof(mchar_async_cache_node_t) * cache->nodes_size);
-
- cache->nodes[0].left = 0;
- cache->nodes[0].right = 0;
- cache->nodes[0].size = 0;
- cache->nodes[0].value = NULL;
-
- cache->index_length = 0;
- cache->index_size = cache->nodes_size;
- cache->index = (size_t*)myhtml_malloc(sizeof(size_t) * cache->index_size);
-}
-
-void mchar_async_cache_clean(mchar_async_cache_t *cache)
-{
- cache->count = 0;
- cache->nodes_root = 0;
- cache->nodes_length = 1;
- cache->index_length = 0;
-
- if(cache->nodes) {
- cache->nodes[0].left = 0;
- cache->nodes[0].right = 0;
- cache->nodes[0].size = 0;
- cache->nodes[0].value = NULL;
- }
-}
-
-mchar_async_cache_t * mchar_async_cache_destroy(mchar_async_cache_t *cache, bool self_destroy)
-{
- if(cache == NULL)
- return NULL;
-
- if(cache->nodes)
- myhtml_free(cache->nodes);
-
- if(cache->index)
- myhtml_free(cache->index);
-
- if(self_destroy) {
- myhtml_free(cache);
- return NULL;
- }
-
- return cache;
-}
-
-size_t mchar_async_cache_malloc(mchar_async_cache_t *cache)
-{
- if(cache->index_length) {
- cache->index_length--;
- return cache->index[cache->index_length];
- }
-
- cache->nodes_length++;
-
- if(cache->nodes_length >= cache->nodes_size) {
- cache->nodes_size <<= 1;
-
- mchar_async_cache_node_t *tmp = (mchar_async_cache_node_t*)myhtml_realloc(cache->nodes, sizeof(mchar_async_cache_node_t) * cache->nodes_size);
-
- if(tmp)
- cache->nodes = tmp;
- }
-
- return cache->nodes_length - 1;
-}
-
-size_t mchar_async_cache_delete(mchar_async_cache_t *cache, size_t size)
-{
- mchar_async_cache_node_t *list = cache->nodes;
- size_t idx = cache->nodes_root;
-
- while (idx)
- {
- if(size <= list[idx].size)
- {
- while( list[ list[idx].right ].size == size )
- idx = list[idx].right;
-
- size_t parent = list[idx].parent;
-
- if(parent) {
- if(list[parent].left == idx)
- {
- if(list[idx].right) {
- if(list[idx].left) {
- size_t last_left = list[ list[idx].right ].left;
-
- while( list[last_left].left )
- last_left = list[last_left].left;
-
- if(last_left) {
- list[last_left].left = list[idx].left;
- list[ list[idx].left ].parent = last_left;
- }
- else {
- list[ list[idx].right ].left = list[idx].left;
- }
- }
-
- list[parent].left = list[idx].right;
- list[ list[idx].right ].parent = parent;
- }
- else {
- list[parent].left = list[idx].left;
- list[ list[idx].left ].parent = parent;
- }
- }
- else {
- if(list[idx].left) {
- if(list[idx].right) {
- size_t last_right = list[ list[idx].left ].right;
-
- while( list[last_right].right )
- last_right = list[last_right].right;
-
- if(last_right) {
- list[last_right].right = list[idx].right;
- list[ list[idx].right ].parent = last_right;
- }
- else {
- list[ list[idx].left ].right = list[idx].right;
- }
- }
-
- list[parent].right = list[idx].left;
- list[ list[idx].left ].parent = parent;
- }
- else {
- list[parent].right = list[idx].right;
- list[ list[idx].right ].parent = parent;
- }
- }
- }
- else {
- if(list[idx].left) {
- if(list[idx].right) {
- size_t last_right = list[ list[idx].left ].right;
-
- while( list[last_right].right )
- last_right = list[last_right].right;
-
- if(last_right) {
- list[last_right].right = list[idx].right;
- list[ list[idx].right ].parent = last_right;
- }
- else {
- list[ list[idx].left ].right = list[idx].right;
- }
- }
-
- cache->nodes_root = list[idx].left;
- list[ list[idx].left ].parent = 0;
- }
- else {
- cache->nodes_root = list[idx].right;
- list[ list[idx].right ].parent = 0;
- }
- }
-
- cache->index[cache->index_length] = idx;
-
- cache->index_length++;
- if(cache->index_length >= cache->index_size)
- {
- size_t new_size = cache->index_size << 1;
- size_t *tmp = (size_t*)myhtml_realloc(cache->index, sizeof(size_t) * new_size);
-
- if(tmp) {
- cache->index = tmp;
- cache->index_size = new_size;
- }
- }
-
- cache->count--;
-
- return idx;
- }
- else {
- idx = list[idx].right;
- }
- }
-
- return 0;
-}
-
-void mchar_async_cache_add(mchar_async_cache_t *cache, void* value, size_t size)
-{
- cache->count++;
-
- if(cache->nodes_root == 0) {
- mchar_async_cache_node_t *list = cache->nodes;
-
- cache->nodes_root = mchar_async_cache_malloc(cache);
-
- list[cache->nodes_root].parent = 0;
- list[cache->nodes_root].left = 0;
- list[cache->nodes_root].right = 0;
- list[cache->nodes_root].size = size;
- list[cache->nodes_root].value = value;
-
- return;
- }
-
- size_t idx = cache->nodes_root;
- size_t new_idx = mchar_async_cache_malloc(cache);
-
- mchar_async_cache_node_t *list = cache->nodes;
-
- while(idx)
- {
- if(size == list[idx].size)
- {
- if(list[idx].right) {
- list[new_idx].right = list[idx].right;
- list[ list[idx].right ].parent = new_idx;
- }
- else {
- list[new_idx].right = 0;
- }
-
- list[idx].right = new_idx;
-
- list[new_idx].parent = idx;
- list[new_idx].left = 0;
- list[new_idx].size = size;
- list[new_idx].value = value;
-
- break;
- }
- else if(size < list[idx].size)
- {
- size_t parent = list[idx].parent;
-
- if(parent) {
- if(list[parent].left == idx)
- list[parent].left = new_idx;
- else
- list[parent].right = new_idx;
-
- list[new_idx].parent = parent;
- }
- else {
- cache->nodes_root = new_idx;
- list[new_idx].parent = 0;
- }
-
- list[idx].parent = new_idx;
-
- list[new_idx].right = idx;
- list[new_idx].left = 0;
- list[new_idx].size = size;
- list[new_idx].value = value;
-
- break;
- }
- else // size > list[idx].size
- {
- if(list[idx].right)
- idx = list[idx].right;
- else {
- list[idx].right = new_idx;
-
- list[new_idx].right = 0;
- list[new_idx].left = 0;
- list[new_idx].parent = idx;
- list[new_idx].size = size;
- list[new_idx].value = value;
-
- break;
- }
- }
- }
-}
-
-
diff --git a/source/myhtml/utils/mchar_async.h b/source/myhtml/utils/mchar_async.h
deleted file mode 100644
index dcba9c5..0000000
--- a/source/myhtml/utils/mchar_async.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- Copyright (C) 2015-2016 Alexander Borisov
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
- Author: lex.borisov@gmail.com (Alexander Borisov)
-*/
-
-#ifndef MyHTML_UTILS_MCHAR_ASYNC_H
-#define MyHTML_UTILS_MCHAR_ASYNC_H
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "myhtml/myosi.h"
-#include "myhtml/utils/mcsync.h"
-
-#define mchar_async_cache_has_nodes(cache) cache.count
-
-typedef struct mchar_async_node mchar_async_node_t;
-
-struct mchar_async_cache_node {
- void *value;
- size_t size;
-
- size_t left;
- size_t right;
- size_t parent;
-}
-typedef mchar_async_cache_node_t;
-
-struct mchar_async_chunk {
- char *begin;
- size_t length;
- size_t size;
-
- struct mchar_async_chunk *next;
- struct mchar_async_chunk *prev;
-}
-typedef mchar_async_chunk_t;
-
-struct mchar_async_cache {
- mchar_async_cache_node_t *nodes;
- size_t nodes_size;
- size_t nodes_length;
- size_t nodes_root;
-
- size_t count;
-
- size_t *index;
- size_t index_length;
- size_t index_size;
-}
-typedef mchar_async_cache_t;
-
-struct mchar_async_node {
- mchar_async_chunk_t *chunk;
- mchar_async_cache_t cache;
-};
-
-struct mchar_async {
- size_t origin_size;
-
- mchar_async_chunk_t **chunks;
- size_t chunks_pos_size;
- size_t chunks_pos_length;
- size_t chunks_size;
- size_t chunks_length;
-
- mchar_async_cache_t chunk_cache;
-
- mchar_async_node_t *nodes;
- size_t nodes_length;
- size_t nodes_size;
-
- size_t *nodes_cache;
- size_t nodes_cache_length;
- size_t nodes_cache_size;
-
- mcsync_t *mcsync;
-}
-typedef mchar_async_t;
-
-
-mchar_async_t * mchar_async_create(size_t pos_size, size_t size);
-void mchar_async_init(mchar_async_t *mchar_async, size_t chunk_len, size_t char_size);
-void mchar_async_clean(mchar_async_t *mchar_async);
-mchar_async_t * mchar_async_destroy(mchar_async_t *mchar_async, int destroy_self);
-
-char * mchar_async_malloc(mchar_async_t *mchar_async, size_t node_idx, size_t size);
-char * mchar_async_realloc(mchar_async_t *mchar_async, size_t node_idx, char *data, size_t data_len, size_t new_size);
-void mchar_async_free(mchar_async_t *mchar_async, size_t node_idx, char *entry);
-
-size_t mchar_async_node_add(mchar_async_t *mchar_async);
-void mchar_async_node_clean(mchar_async_t *mchar_async, size_t node_idx);
-void mchar_async_node_delete(mchar_async_t *mchar_async, size_t node_idx);
-
-mchar_async_chunk_t * mchar_async_chunk_malloc(mchar_async_t *mchar_async, mchar_async_node_t *node, size_t length);
-char * mchar_async_crop_first_chars(mchar_async_t *mchar_async, size_t node_idx, char *data, size_t crop_len);
-char * mchar_async_crop_first_chars_without_cache(char *data, size_t crop_len);
-
-size_t mchar_async_get_size_by_data(const char *data);
-
-// cache
-void mchar_async_cache_init(mchar_async_cache_t *cache);
-mchar_async_cache_t * mchar_async_cache_destroy(mchar_async_cache_t *cache, bool self_destroy);
-void mchar_async_cache_clean(mchar_async_cache_t *cache);
-
-void mchar_async_cache_add(mchar_async_cache_t *cache, void* value, size_t size);
-size_t mchar_async_cache_delete(mchar_async_cache_t *cache, size_t size);
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-#endif /* mchar_async_h */
-
diff --git a/source/myhtml/utils/mcobject.c b/source/myhtml/utils/mcobject.c
deleted file mode 100644
index 3353909..0000000
--- a/source/myhtml/utils/mcobject.c
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- Copyright (C) 2015-2016 Alexander Borisov
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
- Author: lex.borisov@gmail.com (Alexander Borisov)
-*/
-
-#include "myhtml/utils/mcobject.h"
-
-mcobject_t * mcobject_create(void)
-{
- return myhtml_calloc(1, sizeof(mcobject_t));
-}
-
-myhtml_status_t mcobject_init(mcobject_t *mcobject, size_t chunk_size, size_t struct_size)
-{
- mcobject->struct_size = struct_size;
- mcobject->chunk_size = chunk_size;
-
- mcobject->chunk = NULL;
-
- mcobject->cache_length = 0;
- mcobject->cache_size = chunk_size;
- mcobject->cache = (void**)myhtml_malloc(sizeof(void*) * mcobject->cache_size);
-
- if(mcobject->cache == NULL)
- return MyHTML_STATUS_MCOBJECT_ERROR_CACHE_CREATE;
-
- return MyHTML_STATUS_OK;
-}
-
-void mcobject_clean(mcobject_t *mcobject)
-{
- if(mcobject->chunk == NULL)
- return;
-
- mcobject_chunk_t* chunk = mcobject->chunk;
-
- while(chunk->next)
- chunk = chunk->next;
-
- while(chunk) {
- mcobject_chunk_t* tmp = chunk->prev;
-
- if(chunk->begin) {
- myhtml_free(chunk->begin);
- }
-
- myhtml_free(chunk);
-
- chunk = tmp;
- }
-
- mcobject->chunk = NULL;
- mcobject->cache_length = 0;
-}
-
-mcobject_t * mcobject_destroy(mcobject_t *mcobject, bool destroy_self)
-{
- if(mcobject == NULL)
- return NULL;
-
- mcobject_clean(mcobject);
-
- if(mcobject->cache) {
- myhtml_free(mcobject->cache);
- mcobject->cache = NULL;
- }
-
- if(destroy_self) {
- myhtml_free(mcobject);
- return NULL;
- }
-
- return mcobject;
-}
-
-void mcobject_chunk_malloc(mcobject_t* mcobject, myhtml_status_t* status)
-{
- if(status)
- *status = MyHTML_STATUS_OK;
-
- mcobject_chunk_t* chunk;
-
- if(mcobject->chunk && mcobject->chunk->next) {
- mcobject->chunk = mcobject->chunk->next;
-
- mcobject->chunk->length = 0;
-
- return;
- }
- else {
- chunk = myhtml_calloc(1, sizeof(mcobject_chunk_t));
-
- if(chunk == NULL) {
- if(status)
- *status = MyHTML_STATUS_MCOBJECT_ERROR_CHUNK_CREATE;
-
- return;
- }
-
- chunk->begin = myhtml_malloc(mcobject->struct_size * mcobject->chunk_size);
-
- if(chunk->begin == NULL) {
- if(status)
- *status = MyHTML_STATUS_MCOBJECT_ERROR_CHUNK_INIT;
-
- myhtml_free(chunk);
- return;
- }
-
- chunk->size = mcobject->chunk_size;
- }
-
- if(mcobject->chunk == NULL) {
- mcobject->chunk = chunk;
- return;
- }
-
- chunk->prev = mcobject->chunk;
- mcobject->chunk->next = chunk;
-
- mcobject->chunk = chunk;
-}
-
-void * mcobject_malloc(mcobject_t *mcobject, myhtml_status_t* status)
-{
- if(mcobject->cache_length) {
- if(status)
- *status = MyHTML_STATUS_OK;
-
- mcobject->cache_length--;
- return mcobject->cache[ mcobject->cache_length ];
- }
-
- mcobject_chunk_t* chunk = mcobject->chunk;
-
- if(chunk == NULL || chunk->length >= chunk->size)
- {
- myhtml_status_t ns_status;
- mcobject_chunk_malloc(mcobject, &ns_status);
-
- if(ns_status) {
- if(status)
- *status = ns_status;
-
- return NULL;
- }
-
- chunk = mcobject->chunk;
- }
-
- if(status)
- *status = MyHTML_STATUS_OK;
-
- chunk->length++;
- return &chunk->begin[((chunk->length - 1) * mcobject->struct_size)];
-}
-
-myhtml_status_t mcobject_free(mcobject_t *mcobject, void *entry)
-{
- if(mcobject->cache_length >= mcobject->cache_size) {
- size_t new_size = mcobject->cache_size << 1;
-
- void **tmp = (void**)myhtml_realloc(mcobject->cache, sizeof(void*) * new_size);
-
- if(tmp) {
- mcobject->cache = tmp;
- mcobject->cache_size = new_size;
- }
- else
- return MyHTML_STATUS_MCOBJECT_ERROR_CACHE_REALLOC;
- }
-
- mcobject->cache[ mcobject->cache_length ] = entry;
- mcobject->cache_length++;
-
- return MyHTML_STATUS_OK;
-}
-
-
diff --git a/source/myhtml/utils/mcobject.h b/source/myhtml/utils/mcobject.h
deleted file mode 100644
index b68935b..0000000
--- a/source/myhtml/utils/mcobject.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- Copyright (C) 2015-2016 Alexander Borisov
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
- Author: lex.borisov@gmail.com (Alexander Borisov)
-*/
-
-#ifndef MyHTML_UTILS_MCOBJECT_H
-#define MyHTML_UTILS_MCOBJECT_H
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "myhtml/myosi.h"
-
-struct mcobject_chunk {
- unsigned char *begin;
- size_t length;
- size_t size;
-
- struct mcobject_chunk *next;
- struct mcobject_chunk *prev;
-}
-typedef mcobject_chunk_t;
-
-struct mcobject {
- mcobject_chunk_t *chunk;
-
- void **cache;
- size_t cache_size;
- size_t cache_length;
-
- size_t struct_size;
- size_t chunk_size;
-}
-typedef mcobject_t;
-
-
-mcobject_t * mcobject_create(void);
-myhtml_status_t mcobject_init(mcobject_t *mcobject, size_t chunk_size, size_t struct_size);
-void mcobject_clean(mcobject_t *mcobject);
-mcobject_t * mcobject_destroy(mcobject_t *mcobject, bool destroy_self);
-
-void mcobject_chunk_malloc(mcobject_t* mcobject, myhtml_status_t* status);
-
-void * mcobject_malloc(mcobject_t *mcobject, myhtml_status_t* status);
-myhtml_status_t mcobject_free(mcobject_t *mcobject, void *entry);
-
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-#endif /* MyHTML_UTILS_MCOBJECT_H */
-
diff --git a/source/myhtml/utils/mcobject_async.c b/source/myhtml/utils/mcobject_async.c
deleted file mode 100644
index 21e36e8..0000000
--- a/source/myhtml/utils/mcobject_async.c
+++ /dev/null
@@ -1,475 +0,0 @@
-/*
- Copyright (C) 2015-2016 Alexander Borisov
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
- Author: lex.borisov@gmail.com (Alexander Borisov)
-*/
-
-#include "myhtml/utils/mcobject_async.h"
-
-mcobject_async_t * mcobject_async_create(void)
-{
- return (mcobject_async_t*)myhtml_calloc(1, sizeof(mcobject_async_t));
-}
-
-mcobject_async_status_t mcobject_async_chunk_up(mcobject_async_t *mcobj_async)
-{
- mcobj_async->chunks_length = 0;
-
- if(mcobj_async->chunks[ mcobj_async->chunks_pos_length ] == NULL) {
- mcobj_async->chunks[ mcobj_async->chunks_pos_length ] = (mcobject_async_chunk_t*)myhtml_calloc(mcobj_async->chunks_size, sizeof(mcobject_async_chunk_t));
-
- if(mcobj_async->chunks[ mcobj_async->chunks_pos_length ] == NULL)
- return MCOBJECT_ASYNC_STATUS_CHUNK_ERROR_MEMORY_ALLOCATION;
- }
-
- return MCOBJECT_ASYNC_STATUS_OK;
-}
-
-mcobject_async_status_t mcobject_async_init(mcobject_async_t *mcobj_async, size_t chunk_len, size_t obj_size_by_one_chunk, size_t struct_size)
-{
- mcobj_async->origin_size = obj_size_by_one_chunk;
- mcobj_async->struct_size = struct_size;
- mcobj_async->struct_size_sn = struct_size + sizeof(size_t);
-
- mcobj_async->chunks_pos_length = 0;
- mcobj_async->chunks_pos_size = 128;
- mcobj_async->chunks_size = chunk_len;
- mcobj_async->chunks = (mcobject_async_chunk_t**)myhtml_calloc(mcobj_async->chunks_pos_size, sizeof(mcobject_async_chunk_t*));
-
- if(mcobj_async->chunks == NULL)
- return MCOBJECT_ASYNC_STATUS_CHUNK_ERROR_MEMORY_ALLOCATION;
-
- mcobject_async_chunk_up(mcobj_async);
-
- mcobj_async->chunk_cache_size = mcobj_async->chunks_size;
- mcobj_async->chunk_cache = (mcobject_async_chunk_t**)myhtml_calloc(mcobj_async->chunk_cache_size, sizeof(mcobject_async_chunk_t*));
-
- if(mcobj_async->chunk_cache == NULL)
- return MCOBJECT_ASYNC_STATUS_CHUNK_CACHE_ERROR_MEMORY_ALLOCATION;
-
- mcobj_async->nodes_length = 0;
- mcobj_async->nodes_size = 64;
- mcobj_async->nodes = (mcobject_async_node_t*)myhtml_calloc(mcobj_async->nodes_size, sizeof(mcobject_async_node_t));
-
- if(mcobj_async->nodes == NULL)
- return MCOBJECT_ASYNC_STATUS_NODES_ERROR_MEMORY_ALLOCATION;
-
- mcobj_async->nodes_cache_length = 0;
- mcobj_async->nodes_cache_size = mcobj_async->nodes_size;
- mcobj_async->nodes_cache = (size_t*)myhtml_malloc(mcobj_async->nodes_cache_size * sizeof(size_t));
-
- if(mcobj_async->nodes_cache == NULL)
- return MCOBJECT_ASYNC_STATUS_NODES_ERROR_MEMORY_ALLOCATION;
-
- mcobject_async_clean(mcobj_async);
-
- mcobj_async->mcsync = mcsync_create();
-
- return MCOBJECT_ASYNC_STATUS_OK;
-}
-
-void mcobject_async_clean(mcobject_async_t *mcobj_async)
-{
- if(mcobj_async->chunks[0] != NULL)
- mcobj_async->chunks_pos_length = 1;
- else
- mcobj_async->chunks_pos_length = 0;
-
- mcobj_async->chunks_length = 0;
- mcobj_async->chunk_cache_length = 0;
-
- size_t node_idx;
- for (node_idx = 0; node_idx < mcobj_async->nodes_length; node_idx++)
- {
- mcobject_async_node_t *node = &mcobj_async->nodes[node_idx];
- node->cache_length = 0;
-
- if(node->chunk) {
- node->chunk = mcobject_async_chunk_malloc(mcobj_async, mcobj_async->origin_size, NULL);
- }
- }
-}
-
-mcobject_async_t * mcobject_async_destroy(mcobject_async_t *mcobj_async, int destroy_self)
-{
- if(mcobj_async == NULL)
- return NULL;
-
- if(mcobj_async->nodes)
- {
- for (size_t node_idx = 0; node_idx < mcobj_async->nodes_length; node_idx++)
- {
- mcobject_async_node_t *node = &mcobj_async->nodes[node_idx];
-
- if(node->cache)
- myhtml_free(node->cache);
- }
-
- myhtml_free(mcobj_async->nodes);
- }
-
- if(mcobj_async->nodes_cache) {
- myhtml_free(mcobj_async->nodes_cache);
- }
-
- if(mcobj_async->chunks) {
- for (size_t pos_idx = 0; pos_idx < mcobj_async->chunks_pos_length; pos_idx++) {
- if(mcobj_async->chunks[pos_idx])
- {
- for (size_t idx = 0; idx < mcobj_async->chunks_size; idx++) {
- if(mcobj_async->chunks[pos_idx][idx].begin)
- myhtml_free(mcobj_async->chunks[pos_idx][idx].begin);
- }
-
- myhtml_free(mcobj_async->chunks[pos_idx]);
- }
- }
-
- myhtml_free(mcobj_async->chunks);
- }
-
- if(mcobj_async->chunk_cache) {
- myhtml_free(mcobj_async->chunk_cache);
- }
-
- mcobj_async->mcsync = mcsync_destroy(mcobj_async->mcsync, 1);
-
- memset(mcobj_async, 0, sizeof(mcobject_async_t));
-
- if(destroy_self)
- myhtml_free(mcobj_async);
- else
- return mcobj_async;
-
- return NULL;
-}
-
-mcobject_async_status_t mcobject_async_mem_malloc(mcobject_async_t *mcobj_async, mcobject_async_chunk_t *chunk, size_t length)
-{
- if(chunk->begin) {
- if(length > chunk->size) {
- myhtml_free(chunk->begin);
-
- chunk->size = length + mcobj_async->origin_size;
- chunk->begin = (unsigned char*)myhtml_malloc(chunk->size * mcobj_async->struct_size_sn);
- }
- }
- else {
- chunk->size = mcobj_async->origin_size;
-
- if(length > chunk->size)
- chunk->size += length;
-
- chunk->begin = (unsigned char*)myhtml_malloc(chunk->size * mcobj_async->struct_size_sn);
- }
-
- chunk->length = 0;
-
- if(chunk->begin == NULL)
- return MCOBJECT_ASYNC_STATUS_CHUNK_ERROR_MEMORY_ALLOCATION;
-
- return MCOBJECT_ASYNC_STATUS_OK;
-}
-
-mcobject_async_chunk_t * mcobject_async_chunk_malloc_without_lock(mcobject_async_t *mcobj_async, size_t length, mcobject_async_status_t *status)
-{
- if(status)
- *status = MCOBJECT_ASYNC_STATUS_OK;
-
- if(mcobj_async->chunk_cache_length)
- {
- mcobj_async->chunk_cache_length--;
-
- mcobj_async->chunk_cache[ mcobj_async->chunk_cache_length ]->length = 0;
- mcobj_async->chunk_cache[ mcobj_async->chunk_cache_length ]->next = NULL;
- mcobj_async->chunk_cache[ mcobj_async->chunk_cache_length ]->prev = NULL;
-
- return mcobj_async->chunk_cache[ mcobj_async->chunk_cache_length ];
- }
-
- if(mcobj_async->chunks_length >= mcobj_async->chunks_size)
- {
- if(mcobj_async->chunks_pos_length >= mcobj_async->chunks_pos_size)
- {
- size_t tmp_pos_size = mcobj_async->chunks_pos_size << 1;
- mcobject_async_chunk_t **tmp_pos = myhtml_realloc(mcobj_async->chunks,
- sizeof(mcobject_async_chunk_t*) * tmp_pos_size);
-
- if(tmp_pos)
- {
- memset(&tmp_pos[mcobj_async->chunks_pos_length], 0, (tmp_pos_size - mcobj_async->chunks_pos_length)
- * sizeof(mcobject_async_chunk_t*));
-
- mcobj_async->chunks_pos_size = tmp_pos_size;
- mcobj_async->chunks = tmp_pos;
- }
- else {
- if(status)
- *status = MCOBJECT_ASYNC_STATUS_CHUNK_ERROR_MEMORY_ALLOCATION;
-
- return NULL;
- }
- }
-
- if(mcobject_async_chunk_up(mcobj_async)) {
- if(status)
- *status = MCOBJECT_ASYNC_STATUS_CHUNK_ERROR_MEMORY_ALLOCATION;
-
- return NULL;
- }
-
- mcobj_async->chunks_pos_length++;
- }
-
- mcobject_async_chunk_t* chunk = &mcobj_async->chunks[mcobj_async->chunks_pos_length - 1][mcobj_async->chunks_length];
- mcobj_async->chunks_length++;
-
- chunk->next = NULL;
- chunk->prev = NULL;
-
- if(status)
- *status = mcobject_async_mem_malloc(mcobj_async, chunk, length);
- else
- mcobject_async_mem_malloc(mcobj_async, chunk, length);
-
- return chunk;
-}
-
-mcobject_async_chunk_t * mcobject_async_chunk_malloc(mcobject_async_t *mcobj_async, size_t length, mcobject_async_status_t *status)
-{
- mcsync_lock(mcobj_async->mcsync);
- mcobject_async_chunk_t* chunk = mcobject_async_chunk_malloc_without_lock(mcobj_async, length, status);
- mcsync_unlock(mcobj_async->mcsync);
-
- return chunk;
-}
-
-size_t mcobject_async_node_add(mcobject_async_t *mcobj_async, mcobject_async_status_t *status)
-{
- mcsync_lock(mcobj_async->mcsync);
-
- if(status)
- *status = MCOBJECT_ASYNC_STATUS_OK;
-
- size_t node_idx;
-
- if(mcobj_async->nodes_cache_length) {
- mcobj_async->nodes_cache_length--;
-
- node_idx = mcobj_async->nodes_cache[ mcobj_async->nodes_cache_length ];
- }
- else {
- if(mcobj_async->nodes_length >= mcobj_async->nodes_size) {
- mcsync_unlock(mcobj_async->mcsync);
- return 0;
- }
-
- node_idx = mcobj_async->nodes_length;
- mcobj_async->nodes_length++;
- }
-
- mcobject_async_node_t *node = &mcobj_async->nodes[node_idx];
-
- node->chunk = mcobject_async_chunk_malloc_without_lock(mcobj_async, mcobj_async->origin_size, status);
-
- if(status && *status) {
- mcsync_unlock(mcobj_async->mcsync);
- return 0;
- }
-
- node->chunk->next = NULL;
- node->chunk->prev = NULL;
-
- node->cache_length = 0;
- node->cache_size = mcobj_async->origin_size;
- node->cache = (void**)myhtml_malloc(sizeof(void*) * node->cache_size);
-
- if(node->cache == NULL) {
- if(status)
- *status = MCOBJECT_ASYNC_STATUS_CHUNK_CACHE_ERROR_MEMORY_ALLOCATION;
-
- mcsync_unlock(mcobj_async->mcsync);
- return 0;
- }
-
- mcsync_unlock(mcobj_async->mcsync);
-
- return node_idx;
-}
-
-void mcobject_async_node_clean(mcobject_async_t *mcobj_async, size_t node_idx)
-{
- if(mcobj_async->nodes_length <= node_idx)
- return;
-
- mcobject_async_node_t *node = &mcobj_async->nodes[node_idx];
- node->cache_length = 0;
-
- if(node->chunk == NULL)
- return;
-
- while (node->chunk->prev)
- node->chunk = node->chunk->prev;
-
- node->chunk->length = 0;
- node->cache_length = 0;
-}
-
-void mcobject_async_node_all_clean(mcobject_async_t *mcobj_async)
-{
- for (size_t node_idx = 0; node_idx < mcobj_async->nodes_length; node_idx++) {
- mcobject_async_node_clean(mcobj_async, node_idx);
- }
-}
-
-void mcobject_async_node_delete(mcobject_async_t *mcobj_async, size_t node_idx)
-{
- mcsync_lock(mcobj_async->mcsync);
-
- if(mcobj_async->nodes_length <= node_idx) {
- mcsync_unlock(mcobj_async->mcsync);
- return;
- }
-
- mcobject_async_node_t *node = &mcobj_async->nodes[node_idx];
- mcobject_async_chunk_t *chunk = node->chunk;
-
- while (chunk->next)
- chunk = chunk->next;
-
- while (chunk)
- {
- if(mcobj_async->chunk_cache_length >= mcobj_async->chunk_cache_size) {
- size_t new_size = mcobj_async->chunk_cache_size << 1;
-
- mcobject_async_chunk_t **tmp = (mcobject_async_chunk_t**)myhtml_realloc(mcobj_async->chunk_cache,
- sizeof(mcobject_async_chunk_t*) * new_size);
-
- if(tmp) {
- mcobj_async->chunk_cache_size = new_size;
- mcobj_async->chunk_cache = tmp;
- }
- else {
- // TODO: add return status
- mcsync_unlock(mcobj_async->mcsync);
- return;
- }
- }
-
- mcobj_async->chunk_cache[ mcobj_async->chunk_cache_length ] = chunk;
- mcobj_async->chunk_cache_length++;
-
- chunk = chunk->prev;
- }
-
- if(node->cache)
- myhtml_free(node->cache);
-
- memset(node, 0, sizeof(mcobject_async_node_t));
-
- if(mcobj_async->nodes_cache_length >= mcobj_async->nodes_cache_size) {
- size_t new_size = mcobj_async->nodes_cache_size << 1;
-
- size_t *tmp = (size_t*)myhtml_realloc(mcobj_async->nodes_cache, sizeof(size_t) * mcobj_async->nodes_cache_size);
-
- if(tmp) {
- mcobj_async->nodes_cache = tmp;
- mcobj_async->nodes_cache_size = new_size;
- }
- }
-
- mcobj_async->nodes_cache[ mcobj_async->nodes_cache_length ] = node_idx;
- mcobj_async->nodes_cache_length++;
-
- mcsync_unlock(mcobj_async->mcsync);
-}
-
-void * mcobject_async_malloc(mcobject_async_t *mcobj_async, size_t node_idx, mcobject_async_status_t *status)
-{
- mcobject_async_node_t *node = &mcobj_async->nodes[node_idx];
-
- if(node->cache_length) {
- if(status)
- *status = MCOBJECT_ASYNC_STATUS_OK;
-
- node->cache_length--;
- return node->cache[ node->cache_length ];
- }
-
- if(node->chunk->length >= node->chunk->size)
- {
- if(node->chunk->next) {
- node->chunk = node->chunk->next;
- node->chunk->length = 0;
- }
- else {
- mcobject_async_status_t mystatus;
- mcobject_async_chunk_t *chunk = mcobject_async_chunk_malloc(mcobj_async, mcobj_async->origin_size, &mystatus);
-
- if(mystatus) {
- if(status)
- *status = mystatus;
-
- return NULL;
- }
-
- chunk->prev = node->chunk;
- node->chunk->next = chunk;
-
- node->chunk = chunk;
- }
- }
-
- if(status)
- *status = MCOBJECT_ASYNC_STATUS_OK;
-
- size_t offset = node->chunk->length * mcobj_async->struct_size_sn;
- *((size_t*)(&node->chunk->begin[offset])) = node_idx;
-
- node->chunk->length++;
- return &node->chunk->begin[(offset + sizeof(size_t))];
-}
-
-mcobject_async_status_t mcobject_async_free(mcobject_async_t *mcobj_async, void *entry)
-{
- size_t node_idx = *((size_t*)((unsigned char*)entry - sizeof(size_t)));
-
- if(node_idx >= mcobj_async->nodes_length)
- return MCOBJECT_ASYNC_STATUS_NODES_ERROR_BAD_NODE_ID;
-
- mcobject_async_node_t *node = &mcobj_async->nodes[node_idx];
-
- if(node->cache_length >= node->cache_size) {
- size_t new_size = node->cache_size << 1;
-
- void **tmp = (void**)myhtml_realloc(node->cache, sizeof(void*) * new_size);
-
- if(tmp) {
- node->cache = tmp;
- node->cache_size = new_size;
- }
- else
- return MCOBJECT_ASYNC_STATUS_CACHE_ERROR_MEMORY_REALLOC;
- }
-
- node->cache[ node->cache_length ] = entry;
- node->cache_length++;
-
- return MCOBJECT_ASYNC_STATUS_OK;
-}
-
-
diff --git a/source/myhtml/utils/mcobject_async.h b/source/myhtml/utils/mcobject_async.h
deleted file mode 100644
index 8ee1c78..0000000
--- a/source/myhtml/utils/mcobject_async.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- Copyright (C) 2015-2016 Alexander Borisov
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
- Author: lex.borisov@gmail.com (Alexander Borisov)
-*/
-
-#ifndef MyHTML_UTILS_MCOBJECT_ASYNC_H
-#define MyHTML_UTILS_MCOBJECT_ASYNC_H
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "myhtml/myosi.h"
-#include "myhtml/utils/mcsync.h"
-
-enum mcobject_async_status {
- MCOBJECT_ASYNC_STATUS_OK = 0,
- MCOBJECT_ASYNC_STATUS_ERROR_MEMORY_ALLOCATION = 1,
- MCOBJECT_ASYNC_STATUS_CHUNK_ERROR_MEMORY_ALLOCATION = 2,
- MCOBJECT_ASYNC_STATUS_CHUNK_CACHE_ERROR_MEMORY_ALLOCATION = 3,
- MCOBJECT_ASYNC_STATUS_NODES_ERROR_MEMORY_ALLOCATION = 4,
- MCOBJECT_ASYNC_STATUS_NODES_ERROR_BAD_NODE_ID = 5,
- MCOBJECT_ASYNC_STATUS_CACHE_ERROR_MEMORY_REALLOC = 6
-}
-typedef mcobject_async_status_t;
-
-struct mcobject_async_chunk {
- unsigned char *begin;
- size_t length;
- size_t size;
-
- struct mcobject_async_chunk *next;
- struct mcobject_async_chunk *prev;
-}
-typedef mcobject_async_chunk_t;
-
-struct mcobject_async_node {
- mcobject_async_chunk_t *chunk;
-
- void **cache;
- size_t cache_size;
- size_t cache_length;
-}
-typedef mcobject_async_node_t;
-
-struct mcobject_async {
- size_t origin_size;
- size_t struct_size;
- size_t struct_size_sn;
-
- mcobject_async_chunk_t **chunk_cache;
- size_t chunk_cache_size;
- size_t chunk_cache_length;
-
- mcobject_async_chunk_t **chunks;
- size_t chunks_pos_size;
- size_t chunks_pos_length;
- size_t chunks_size;
- size_t chunks_length;
-
- mcobject_async_node_t *nodes;
- size_t nodes_length;
- size_t nodes_size;
-
- size_t *nodes_cache;
- size_t nodes_cache_length;
- size_t nodes_cache_size;
-
- mcsync_t *mcsync;
-}
-typedef mcobject_async_t;
-
-mcobject_async_t * mcobject_async_create(void);
-mcobject_async_status_t mcobject_async_init(mcobject_async_t *mcobj_async, size_t chunk_len, size_t obj_size_by_one_chunk, size_t struct_size);
-
-void mcobject_async_clean(mcobject_async_t *mcobj_async);
-mcobject_async_t * mcobject_async_destroy(mcobject_async_t *mcobj_async, int destroy_self);
-
-size_t mcobject_async_node_add(mcobject_async_t *mcobj_async, mcobject_async_status_t *status);
-void mcobject_async_node_clean(mcobject_async_t *mcobj_async, size_t node_idx);
-void mcobject_async_node_all_clean(mcobject_async_t *mcobj_async);
-void mcobject_async_node_delete(mcobject_async_t *mcobj_async, size_t node_idx);
-
-void * mcobject_async_malloc(mcobject_async_t *mcobj_async, size_t node_idx, mcobject_async_status_t *status);
-mcobject_async_status_t mcobject_async_free(mcobject_async_t *mcobj_async, void *entry);
-
-mcobject_async_chunk_t * mcobject_async_chunk_malloc(mcobject_async_t *mcobj_async, size_t length, mcobject_async_status_t *status);
-mcobject_async_chunk_t * mcobject_async_chunk_malloc_without_lock(mcobject_async_t *mcobj_async, size_t length, mcobject_async_status_t *status);
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-#endif /* mcobject_async_h */
-
-
-
-
diff --git a/source/myhtml/utils/mcsimple.c b/source/myhtml/utils/mcsimple.c
deleted file mode 100644
index 8103b21..0000000
--- a/source/myhtml/utils/mcsimple.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- Copyright (C) 2015-2016 Alexander Borisov
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
- Author: lex.borisov@gmail.com (Alexander Borisov)
- */
-
-#include "myhtml/utils/mcsimple.h"
-
-mcsimple_t * mcsimple_create(void)
-{
- return myhtml_calloc(1, sizeof(mcsimple_t));
-}
-
-void mcsimple_init(mcsimple_t *mcsimple, size_t pos_size, size_t list_size, size_t struct_size)
-{
- mcsimple->struct_size = struct_size;
-
- mcsimple->list_pos_length_used = 0;
- mcsimple->list_pos_length = 0;
- mcsimple->list_pos_size = pos_size;
- mcsimple->list = (uint8_t**)myhtml_calloc(pos_size, sizeof(uint8_t*));
-
- if(mcsimple->list == NULL) {
- return;
- }
-
- mcsimple->list_size = list_size * struct_size;
-
- if((mcsimple_init_list_entries(mcsimple, mcsimple->list_pos_length) == NULL)) {
- return;
- }
-}
-
-void mcsimple_clean(mcsimple_t *mcsimple)
-{
- mcsimple->list_length = 0;
- mcsimple->list_pos_length = 0;
-}
-
-mcsimple_t * mcsimple_destroy(mcsimple_t *mcsimple, bool destroy_self)
-{
- if(mcsimple == NULL)
- return NULL;
-
- if(mcsimple->list) {
- for(size_t i = 0; i < mcsimple->list_pos_length_used; i++) {
- if(mcsimple->list[i])
- free(mcsimple->list[i]);
- }
-
- free(mcsimple->list);
- }
-
- if(destroy_self) {
- free(mcsimple);
- return NULL;
- }
-
- return mcsimple;
-}
-
-uint8_t * mcsimple_init_list_entries(mcsimple_t *mcsimple, size_t pos)
-{
- if(mcsimple->list_pos_length >= mcsimple->list_pos_size)
- {
- size_t new_size = mcsimple->list_pos_size + 128;
- uint8_t **list = (uint8_t**)myhtml_realloc(mcsimple->list, mcsimple->list_pos_size * sizeof(uint8_t*));
-
- if(list) {
- mcsimple->list = list;
- memset(&mcsimple->list[pos], 0, (new_size - mcsimple->list_pos_size) * sizeof(uint8_t*));
-
- mcsimple->list_pos_size = new_size;
- }
- else
- return NULL;
- }
-
- mcsimple->list_length = 0;
-
- if(mcsimple->list[pos] == NULL) {
- mcsimple->list_pos_length_used++;
- mcsimple->list[pos] = (uint8_t*)myhtml_malloc(mcsimple->list_size * sizeof(uint8_t));
- }
-
- return mcsimple->list[pos];
-}
-
-void * mcsimple_malloc(mcsimple_t *mcsimple)
-{
- if(mcsimple->list_length >= mcsimple->list_size)
- {
- mcsimple->list_pos_length++;
- if((mcsimple_init_list_entries(mcsimple, mcsimple->list_pos_length) == NULL)) {
- return NULL;
- }
- }
-
- size_t current = mcsimple->list_length;
- mcsimple->list_length += mcsimple->struct_size;
-
- return &mcsimple->list[mcsimple->list_pos_length][current];
-}
-
-void * mcsimple_get_by_absolute_position(mcsimple_t *mcsimple, size_t pos)
-{
- pos *= mcsimple->struct_size;
- return &mcsimple->list[ (pos / mcsimple->list_size) ][ (pos % mcsimple->list_size) ];
-}
-
-
diff --git a/source/myhtml/utils/mcsimple.h b/source/myhtml/utils/mcsimple.h
deleted file mode 100644
index be972d9..0000000
--- a/source/myhtml/utils/mcsimple.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- Copyright (C) 2015-2016 Alexander Borisov
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
- Author: lex.borisov@gmail.com (Alexander Borisov)
-*/
-
-#ifndef MyHTML_UTILS_MCSIMPLE_H
-#define MyHTML_UTILS_MCSIMPLE_H
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "myhtml/myosi.h"
-
-struct mcsimple {
- size_t struct_size;
-
- uint8_t **list;
-
- size_t list_pos_size;
- size_t list_pos_length;
- size_t list_pos_length_used;
- size_t list_size;
- size_t list_length;
-}
-typedef mcsimple_t;
-
-
-mcsimple_t * mcsimple_create(void);
-void mcsimple_init(mcsimple_t *mcsimple, size_t pos_size, size_t list_size, size_t struct_size);
-void mcsimple_clean(mcsimple_t *mcsimple);
-mcsimple_t * mcsimple_destroy(mcsimple_t *mcsimple, bool destroy_self);
-
-uint8_t * mcsimple_init_list_entries(mcsimple_t *mcsimple, size_t pos);
-
-void * mcsimple_malloc(mcsimple_t *mcsimple);
-void * mcsimple_get_by_absolute_position(mcsimple_t *mcsimple, size_t pos);
-
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-#endif /* MyHTML_UTILS_MCSIMPLE_H */
-
diff --git a/source/myhtml/utils/mcsync.c b/source/myhtml/utils/mcsync.c
deleted file mode 100644
index 58b263b..0000000
--- a/source/myhtml/utils/mcsync.c
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- Copyright (C) 2015-2016 Alexander Borisov
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
- Author: lex.borisov@gmail.com (Alexander Borisov)
-*/
-
-#include "myhtml/utils/mcsync.h"
-
-#if !defined(MyHTML_BUILD_WITHOUT_THREADS) && ((defined(__GNUC__) && __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) || \
- defined(__ATOMIC_SEQ_CST))
-#define MyHTML_FORCE_SPINLOCK
-#endif
-
-#if defined(MyHTML_FORCE_SPINLOCK)
-static int mcsync_atomic_compare_exchange(int* ptr, int compare, int exchange)
-{
- return __atomic_compare_exchange_n(ptr, &compare, exchange, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
-}
-
-static void mcsync_atomic_store(int* ptr, int value)
-{
- __atomic_store_n(ptr, 0, __ATOMIC_SEQ_CST);
-}
-#endif
-
-#if !defined(MyHTML_BUILD_WITHOUT_THREADS) && defined(IS_OS_WINDOWS)
-static int pthread_mutex_lock(pthread_mutex_t *mutex)
-{
- EnterCriticalSection(mutex);
- return 0;
-}
-
-static int pthread_mutex_unlock(pthread_mutex_t *mutex)
-{
- LeaveCriticalSection(mutex);
- return 0;
-}
-
-static int pthread_mutex_init(pthread_mutex_t *mutex, pthread_mutexattr_t *attr)
-{
- (void)attr;
- InitializeCriticalSection(mutex);
- return 0;
-}
-
-static int pthread_mutex_destroy(pthread_mutex_t *mutex)
-{
- DeleteCriticalSection(mutex);
- return 0;
-}
-#endif
-
-mcsync_t * mcsync_create(void)
-{
- return calloc(1, sizeof(mcsync_t));
-}
-
-mcsync_status_t mcsync_init(mcsync_t* mcsync)
-{
- mcsync_clean(mcsync);
- return MCSYNC_STATUS_OK;
-}
-
-mcsync_t * mcsync_destroy(mcsync_t* mcsync, int destroy_self)
-{
- if(mcsync == NULL)
- return NULL;
-
-#if !defined(MyHTML_BUILD_WITHOUT_THREADS) && !defined(MyHTML_FORCE_SPINLOCK)
- if(mcsync->mutex) {
- pthread_mutex_destroy(mcsync->mutex);
- myhtml_free(mcsync->mutex);
- }
-#endif
-
- if(destroy_self)
- myhtml_free(mcsync);
-
- return NULL;
-}
-
-void mcsync_clean(mcsync_t* mcsync)
-{
- mcsync->spinlock = 0;
-}
-
-mcsync_status_t mcsync_lock(mcsync_t* mcsync)
-{
-#if defined(MyHTML_FORCE_SPINLOCK)
- while (!mcsync_atomic_compare_exchange(&mcsync->spinlock, 0, 1)) {}
-#elif !defined(MyHTML_BUILD_WITHOUT_THREADS)
- mcsync_mutex_lock(mcsync);
-#endif
-
- return MCSYNC_STATUS_OK;
-}
-
-mcsync_status_t mcsync_unlock(mcsync_t* mcsync)
-{
-#if defined(MyHTML_FORCE_SPINLOCK)
- mcsync_atomic_store(&mcsync->spinlock, 0);
-#elif !defined(MyHTML_BUILD_WITHOUT_THREADS)
- mcsync_mutex_unlock(mcsync);
-#endif
-
- return MCSYNC_STATUS_OK;
-}
-
-mcsync_status_t mcsync_mutex_lock(mcsync_t* mcsync)
-{
-#if !defined(MyHTML_BUILD_WITHOUT_THREADS) && !defined(MyHTML_FORCE_SPINLOCK)
- if(mcsync->mutex == NULL) {
- mcsync->mutex = (pthread_mutex_t*)myhtml_malloc(sizeof(pthread_mutex_t));
-
- if(mcsync->mutex == NULL)
- return MCSYNC_STATUS_ERROR_MEM_ALLOCATE;
-
- pthread_mutex_init(mcsync->mutex, NULL);
- }
-
- if(pthread_mutex_lock(mcsync->mutex) == 0)
- return MCSYNC_STATUS_OK;
- else
- return MCSYNC_STATUS_NOT_OK;
-#else
- return MCSYNC_STATUS_NOT_OK;
-#endif
-}
-
-mcsync_status_t mcsync_mutex_unlock(mcsync_t* mcsync)
-{
-#if !defined(MyHTML_BUILD_WITHOUT_THREADS) && !defined(MyHTML_FORCE_SPINLOCK)
- if(pthread_mutex_unlock(mcsync->mutex) == 0)
- return MCSYNC_STATUS_OK;
- else
- return MCSYNC_STATUS_NOT_OK;
-#else
- return MCSYNC_STATUS_NOT_OK;
-#endif
-}
-
diff --git a/source/myhtml/utils/mcsync.h b/source/myhtml/utils/mcsync.h
deleted file mode 100644
index 671aa1a..0000000
--- a/source/myhtml/utils/mcsync.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- Copyright (C) 2015-2016 Alexander Borisov
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
- Author: lex.borisov@gmail.com (Alexander Borisov)
-*/
-
-#ifndef MyHTML_UTILS_MCSYNC_H
-#define MyHTML_UTILS_MCSYNC_H
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <memory.h>
-
-#include "myhtml/myosi.h"
-
-#if !defined(MyHTML_BUILD_WITHOUT_THREADS)
-#if defined(IS_OS_WINDOWS)
- typedef CRITICAL_SECTION pthread_mutex_t;
- typedef unsigned long pthread_mutexattr_t;
-#else
-# include <pthread.h>
-#endif
-#endif
-
-enum mcsync_status {
- MCSYNC_STATUS_OK = 0,
- MCSYNC_STATUS_NOT_OK = 1,
- MCSYNC_STATUS_ERROR_MEM_ALLOCATE = 2
-}
-typedef mcsync_status_t;
-
-struct mcsync {
- int spinlock;
-#if !defined(MyHTML_BUILD_WITHOUT_THREADS)
- pthread_mutex_t *mutex;
-#endif
-}
-typedef mcsync_t;
-
-mcsync_t * mcsync_create(void);
-mcsync_status_t mcsync_init(mcsync_t* mcsync);
-void mcsync_clean(mcsync_t* mcsync);
-mcsync_t * mcsync_destroy(mcsync_t* mcsync, int destroy_self);
-
-mcsync_status_t mcsync_lock(mcsync_t* mclock);
-mcsync_status_t mcsync_unlock(mcsync_t* mclock);
-
-mcsync_status_t mcsync_mutex_lock(mcsync_t* mclock);
-mcsync_status_t mcsync_mutex_unlock(mcsync_t* mclock);
-
-#if !defined(MyHTML_BUILD_WITHOUT_THREADS) && defined(IS_OS_WINDOWS)
- static int pthread_mutex_lock(pthread_mutex_t *mutex);
- static int pthread_mutex_unlock(pthread_mutex_t *mutex);
- static int pthread_mutex_init(pthread_mutex_t *m, pthread_mutexattr_t *a);
- static int pthread_mutex_destroy(pthread_mutex_t *m);
-#endif
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-#endif /* mcsync_h */
diff --git a/source/myhtml/utils/mctree.c b/source/myhtml/utils/mctree.c
deleted file mode 100644
index 526560c..0000000
--- a/source/myhtml/utils/mctree.c
+++ /dev/null
@@ -1,285 +0,0 @@
-/*
- Copyright (C) 2015-2016 Alexander Borisov
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
- Author: lex.borisov@gmail.com (Alexander Borisov)
-*/
-
-#include "myhtml/utils/resources.h"
-#include "myhtml/utils/mctree.h"
-
-
-mctree_t * mctree_create(size_t start_size)
-{
- mctree_t* mctree = (mctree_t*)myhtml_malloc(sizeof(mctree_t));
-
- mctree->nodes_size = start_size + 512;
- mctree->nodes_length = start_size + 1;
- mctree->nodes = (mctree_node_t*)myhtml_calloc(mctree->nodes_size, sizeof(mctree_node_t));
-
- mctree->start_size = start_size;
-
- return mctree;
-}
-
-void mctree_clean(mctree_t* mctree)
-{
- mctree->nodes_length = mctree->start_size + 1;
- memset(mctree->nodes, 0, sizeof(mctree_node_t) * mctree->nodes_size);
-}
-
-mctree_t * mctree_destroy(mctree_t* mctree)
-{
- if(mctree == NULL)
- return NULL;
-
- if(mctree->nodes)
- myhtml_free(mctree->nodes);
-
- myhtml_free(mctree);
-
- return NULL;
-}
-
-mctree_index_t __mtree_search_lowercase_to_start(mctree_t* mctree, mctree_index_t idx, const char* key, size_t key_size)
-{
- mctree_node_t* nodes = mctree->nodes;
-
- while (idx)
- {
- if(key_size == nodes[idx].str_size) {
- if(myhtml_strncasecmp(key, nodes[idx].str, key_size) == 0) {
- return idx;
- }
-
- idx = nodes[idx].child;
- }
- else if(key_size > nodes[idx].str_size)
- {
- if(key_size < nodes[ nodes[idx].next ].str_size) {
- return 0;
- }
-
- idx = nodes[idx].next;
- }
- else {
- if(key_size > nodes[ nodes[idx].prev ].str_size) {
- return 0;
- }
-
- idx = nodes[idx].prev;
- }
- }
-
- return 0;
-}
-
-mctree_index_t __mtree_search_to_start(mctree_t* mctree, mctree_index_t idx, const char* key, size_t key_size)
-{
- mctree_node_t* nodes = mctree->nodes;
-
- while (idx)
- {
- if(key_size == nodes[idx].str_size) {
- if(memcmp((const void *)key, (const void *)(nodes[idx].str), key_size) == 0) {
- return idx;
- }
-
- idx = nodes[idx].child;
- }
- else if(key_size > nodes[idx].str_size)
- {
- if(key_size < nodes[ nodes[idx].next ].str_size) {
- return 0;
- }
-
- idx = nodes[idx].next;
- }
- else {
- if(key_size > nodes[ nodes[idx].prev ].str_size) {
- return 0;
- }
-
- idx = nodes[idx].prev;
- }
- }
-
- return 0;
-}
-
-mctree_index_t mctree_insert_child(mctree_t* mctree, mctree_index_t idx, const char* key, size_t key_size, void* value)
-{
- mctree_node_t* nodes = mctree->nodes;
- mctree_index_t new_idx = mctree_node_get_free_id(mctree);
-
- nodes[idx].child = new_idx;
-
- nodes[new_idx].str = key;
- nodes[new_idx].str_size = key_size;
- nodes[new_idx].value = value;
-
- mctree_node_add(mctree);
-
- return new_idx;
-}
-
-mctree_index_t mctree_insert_after(mctree_t* mctree, mctree_index_t idx, const char* key, size_t key_size, void* value)
-{
- mctree_node_t* nodes = mctree->nodes;
- mctree_index_t new_idx = mctree_node_get_free_id(mctree);
-
- if(nodes[idx].next) {
- nodes[ nodes[idx].next ].prev = new_idx;
- nodes[new_idx].next = nodes[idx].next;
- }
-
- nodes[idx].next = new_idx;
- nodes[new_idx].prev = idx;
-
- nodes[new_idx].str = key;
- nodes[new_idx].str_size = key_size;
- nodes[new_idx].value = value;
-
- mctree_node_add(mctree);
-
- return new_idx;
-}
-
-mctree_index_t mctree_insert_before(mctree_t* mctree, mctree_index_t idx, const char* key, size_t key_size, void* value)
-{
- mctree_node_t* nodes = mctree->nodes;
- mctree_index_t new_idx = mctree_node_get_free_id(mctree);
-
- if(nodes[idx].prev) {
- nodes[ nodes[idx].prev ].next = new_idx;
- nodes[new_idx].prev = nodes[idx].prev;
- }
-
- nodes[idx].prev = new_idx;
- nodes[new_idx].next = idx;
-
- nodes[new_idx].str = key;
- nodes[new_idx].str_size = key_size;
- nodes[new_idx].value = value;
-
- mctree_node_add(mctree);
-
- return new_idx;
-}
-
-mctree_index_t __mtree_insert_to_start(mctree_t* mctree, mctree_index_t idx, const char* key, size_t key_size, void* value, mctree_before_insert_f b_insert)
-{
- mctree_node_t* nodes = mctree->nodes;
-
- while (idx)
- {
- if(key_size == nodes[idx].str_size) {
- if(memcmp((const void *)key, (const void *)nodes[idx].str, key_size) == 0)
- {
- if(value)
- nodes[idx].value = value;
-
- return idx;
- }
-
- if(nodes[idx].child == 0) {
- if(b_insert)
- b_insert(key, key_size, &value);
-
- return mctree_insert_child(mctree, idx, key, key_size, value);
- }
-
- idx = nodes[idx].child;
- }
- else if(key_size > nodes[idx].str_size)
- {
- if(nodes[idx].next == 0 || key_size < nodes[ nodes[idx].next ].str_size) {
- if(b_insert)
- b_insert(key, key_size, &value);
-
- return mctree_insert_after(mctree, idx, key, key_size, value);
- }
-
- idx = nodes[idx].next;
- }
- else {
- if(nodes[idx].prev == 0 || key_size > nodes[ nodes[idx].prev ].str_size) {
- if(b_insert)
- b_insert(key, key_size, &value);
-
- return mctree_insert_before(mctree, idx, key, key_size, value);
- }
-
- idx = nodes[idx].prev;
- }
- }
-
- return 0;
-}
-
-mctree_index_t mctree_insert(mctree_t* mctree, const char* key, size_t key_size, void* value, mctree_before_insert_f b_insert)
-{
- mctree_node_t* start = mctree->nodes;
-
- if(key_size > 0) {
- mctree_index_t idx = mctree_make_first_idx(mctree, key, key_size);
-
- if(start[idx].child) {
- return __mtree_insert_to_start(mctree, start[idx].child, key, key_size, value, b_insert);
- }
- else {
- if(b_insert)
- b_insert(key, key_size, &value);
-
- return mctree_insert_child(mctree, idx, key, key_size, value);
- }
- }
-
- return 0;
-}
-
-mctree_index_t mctree_search(mctree_t* mctree, const char* key, size_t key_size)
-{
- mctree_node_t* start = mctree->nodes;
-
- if(key_size > 0) {
- mctree_index_t idx = mctree_make_first_idx(mctree, key, key_size);
-
- if(start[idx].child) {
- return __mtree_search_to_start(mctree, start[idx].child, key, key_size);
- }
- }
-
- return 0;
-}
-
-mctree_index_t mctree_search_lowercase(mctree_t* mctree, const char* key, size_t key_size)
-{
- mctree_node_t* start = mctree->nodes;
-
- if(key_size > 0) {
- mctree_index_t idx = mctree_make_first_idx(mctree, key, key_size);
-
- if(start[idx].child) {
- return __mtree_search_lowercase_to_start(mctree, start[idx].child, key, key_size);
- }
- }
-
- return 0;
-}
-
-
-
diff --git a/source/myhtml/utils/mctree.h b/source/myhtml/utils/mctree.h
deleted file mode 100644
index bd3054f..0000000
--- a/source/myhtml/utils/mctree.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- Copyright (C) 2015-2016 Alexander Borisov
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
- Author: lex.borisov@gmail.com (Alexander Borisov)
-*/
-
-#ifndef MyHTML_UTILS_MCTREE_H
-#define MyHTML_UTILS_MCTREE_H
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "myhtml/myosi.h"
-#include "myhtml/utils.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <memory.h>
-
-#define mctree_node_get_free_id(mctree) mctree->nodes_length
-
-#define mctree_node_clean(mctree, idx) \
- mctree->nodes[idx].str = NULL; \
- mctree->nodes[idx].value = NULL; \
- mctree->nodes[idx].child_count = 0; \
- mctree->nodes[idx].prev = 0; \
- mctree->nodes[idx].next = 0; \
- mctree->nodes[idx].child = 0
-
-#define mctree_node_add(mctree) \
- mctree->nodes_length++; \
- if(mctree->nodes_length >= mctree->nodes_size) { \
- mctree->nodes_size = mctree->nodes_length + 4096; \
- mctree->nodes = (mctree_node_t*)myhtml_realloc(mctree->nodes, \
- sizeof(mctree_node_t) * mctree->nodes_size); \
- } \
- mctree_node_clean(mctree, mctree->nodes_length)
-
-#define mctree_make_first_idx(mctree, key, size) \
- ((myhtml_string_chars_lowercase_map[ (const unsigned char)(key[0]) ] + myhtml_string_chars_lowercase_map[ (const unsigned char)(key[size - 1]) ]) % mctree->start_size) + 1
-
-
-typedef size_t mctree_index_t;
-
-struct mctree_node {
- const char* str;
- size_t str_size;
- void* value;
-
- size_t child_count;
- mctree_index_t prev;
- mctree_index_t next;
- mctree_index_t child;
-}
-typedef mctree_node_t;
-
-struct mctree_tree {
- mctree_node_t* nodes;
- size_t nodes_length;
- size_t nodes_size;
-
- size_t start_size;
-}
-typedef mctree_t;
-
-typedef void (*mctree_before_insert_f)(const char* key, size_t key_size, void **value);
-
-
-mctree_t * mctree_create(size_t start_size);
-void mctree_clean(mctree_t* mctree);
-mctree_t * mctree_destroy(mctree_t* mctree);
-
-mctree_index_t mctree_insert(mctree_t* mctree, const char* key, size_t key_size, void* value, mctree_before_insert_f b_insert);
-mctree_index_t mctree_search(mctree_t* mctree, const char* key, size_t key_size);
-mctree_index_t mctree_search_lowercase(mctree_t* mctree, const char* key, size_t key_size);
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-#endif /* defined(__mhtml__mtree__) */
diff --git a/source/myhtml/utils/mhash.c b/source/myhtml/utils/mhash.c
deleted file mode 100644
index 1929f26..0000000
--- a/source/myhtml/utils/mhash.c
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- Copyright (C) 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
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin avl_treet, Fifth Floor, Boston, MA 02110-1301 USA
-
- Author: lex.borisov@gmail.com (Alexander Borisov)
-*/
-
-#include "myhtml/utils/mhash.h"
-
-size_t myhtml_utils_mhash_hash(const char* key, size_t key_size, size_t table_size)
-{
- size_t hash, i;
-
- for(hash = i = 0; i < key_size; i++)
- {
- hash += key[i];
- hash += (hash << 10);
- hash ^= (hash >> 6);
- }
-
- hash += (hash << 3);
- hash ^= (hash >> 11);
- hash += (hash << 15);
-
- return hash % table_size;
-}
-
-myhtml_utils_mhash_t * myhtml_utils_mhash_create(void)
-{
- return myhtml_calloc(1, sizeof(myhtml_utils_mhash_t));
-};
-
-myhtml_status_t myhtml_utils_mhash_init(myhtml_utils_mhash_t* mhash, size_t table_size, size_t max_depth)
-{
- mhash->mchar_obj = mchar_async_create(128, 4096);
- if(mhash->mchar_obj == NULL)
- return MyHTML_STATUS_ATTR_ERROR_ALLOCATION;
-
- mhash->mchar_node = mchar_async_node_add(mhash->mchar_obj);
-
- if(table_size < 128)
- table_size = 128;
-
- mhash->table = myhtml_calloc(table_size, sizeof(myhtml_utils_mhash_entry_t*));
- if(mhash->table == NULL)
- return MyHTML_STATUS_ATTR_ERROR_ALLOCATION;
-
- if(max_depth < 1)
- max_depth = 1;
-
- mhash->table_max_depth = max_depth;
- mhash->table_size = table_size;
-
- return MyHTML_STATUS_OK;
-};
-
-void myhtml_utils_mhash_clean(myhtml_utils_mhash_t* mhash)
-{
- mchar_async_clean(mhash->mchar_obj);
- memset(mhash->table, 0, (sizeof(myhtml_utils_mhash_entry_t*) * mhash->table_size));
-}
-
-myhtml_utils_mhash_t * myhtml_utils_mhash_destroy(myhtml_utils_mhash_t* mhash, bool self_destroy)
-{
- if(mhash == NULL)
- return NULL;
-
- if(mhash->table) {
- myhtml_free(mhash->table);
- mhash->table = NULL;
- }
-
- if(self_destroy) {
- myhtml_free(mhash->table);
- return NULL;
- }
-
- return mhash;
-}
-
-myhtml_utils_mhash_entry_t * myhtml_utils_mhash_create_entry(myhtml_utils_mhash_t* mhash, const char* key, size_t key_size, void* value)
-{
- myhtml_utils_mhash_entry_t *entry = (myhtml_utils_mhash_entry_t*)
- mchar_async_malloc(mhash->mchar_obj, mhash->mchar_node, sizeof(myhtml_utils_mhash_entry_t));
-
- entry->key = mchar_async_malloc(mhash->mchar_obj, mhash->mchar_node, (sizeof(char) * key_size) + 1);
-
- if(entry->key == NULL) {
- mchar_async_free(mhash->mchar_obj, mhash->mchar_node, (char*)entry);
- return NULL;
- }
-
- memcpy(entry->key, key, (sizeof(char) * key_size));
- entry->key[key_size] = '\0';
-
- entry->key_length = key_size;
- entry->value = value;
- entry->next = NULL;
-
- return entry;
-}
-
-myhtml_utils_mhash_entry_t * myhtml_utils_mhash_add_with_choice(myhtml_utils_mhash_t* mhash, const char* key, size_t key_size)
-{
- if(key == NULL || key_size == 0)
- return NULL;
-
- size_t hash_id = myhtml_utils_mhash_hash(key, key_size, mhash->table_size);
-
-
- myhtml_utils_mhash_entry_t *entry;
-
- if(mhash->table[hash_id] == NULL) {
- /* rebuild table if need */
- if(mhash->table_length >= (mhash->table_size - (mhash->table_size / 4))) {
- myhtml_utils_mhash_rebuld(mhash);
- }
-
- mhash->table[hash_id] = myhtml_utils_mhash_create_entry(mhash, key, key_size, NULL);
- return mhash->table[hash_id];
- }
-
- size_t depth = 0;
- entry = mhash->table[hash_id];
-
- do {
- if(entry->key_length == key_size) {
- if(strncmp(entry->key, key, key_size) == 0)
- return entry;
- }
-
- if(entry->next == NULL) {
- entry->next = myhtml_utils_mhash_create_entry(mhash, key, key_size, NULL);
-
- if(depth > mhash->table_max_depth) {
- myhtml_utils_mhash_entry_t *entry_new = entry->next;
- myhtml_utils_mhash_rebuld(mhash);
-
- return entry_new;
- }
-
- return entry->next;
- }
-
- depth++;
- entry = entry->next;
- }
- while(1);
-}
-
-myhtml_utils_mhash_entry_t * myhtml_utils_mhash_add(myhtml_utils_mhash_t* mhash, const char* key, size_t key_size, void* value)
-{
- myhtml_utils_mhash_entry_t *entry = myhtml_utils_mhash_add_with_choice(mhash, key, key_size);
-
- if(entry)
- entry->value = value;
-
- return entry;
-}
-
-myhtml_utils_mhash_entry_t * myhtml_utils_mhash_search(myhtml_utils_mhash_t* mhash, const char* key, size_t key_size, void* value)
-{
- if(key == NULL || key_size == 0)
- return NULL;
-
- size_t hash_id = myhtml_utils_mhash_hash(key, key_size, mhash->table_size);
-
- myhtml_utils_mhash_entry_t *entry = mhash->table[hash_id];
-
- while(entry) {
- if(entry->key_length == key_size) {
- if(strncmp(entry->key, key, key_size) == 0)
- return entry;
- }
-
- entry = entry->next;
- }
-
- return NULL;
-}
-
-myhtml_utils_mhash_entry_t * myhtml_utils_mhash_entry_by_id(myhtml_utils_mhash_t* mhash, size_t id)
-{
- if(mhash->table_size > id)
- return mhash->table[id];
-
- return NULL;
-}
-
-size_t myhtml_utils_mhash_get_table_size(myhtml_utils_mhash_t* mhash)
-{
- return mhash->table_size;
-}
-
-myhtml_utils_mhash_entry_t * myhtml_utils_mhash_rebuild_add_entry(myhtml_utils_mhash_t* mhash, const char* key, size_t key_size, myhtml_utils_mhash_entry_t *ext_entry)
-{
- if(key == NULL || key_size == 0)
- return NULL;
-
- ext_entry->next = NULL;
-
- size_t hash_id = myhtml_utils_mhash_hash(key, key_size, mhash->table_size);
-
- if(mhash->table[hash_id] == NULL) {
- mhash->table[hash_id] = ext_entry;
- return ext_entry;
- }
-
- myhtml_utils_mhash_entry_t *entry = mhash->table[hash_id];
-
- do {
- if(entry->next == NULL) {
- entry->next = ext_entry;
- break;
- }
-
- entry = entry->next;
- }
- while(1);
-
- return ext_entry;
-}
-
-myhtml_utils_mhash_entry_t ** myhtml_utils_mhash_rebuld(myhtml_utils_mhash_t* mhash)
-{
- myhtml_utils_mhash_entry_t **table = mhash->table;
- size_t size = mhash->table_size;
-
- mhash->table_size = mhash->table_size << 1;
- mhash->table = myhtml_calloc(mhash->table_size, sizeof(myhtml_utils_mhash_entry_t*));
-
- if(mhash->table == NULL) {
- mhash->table = table;
- mhash->table_size = size;
-
- return NULL;
- }
-
- for(size_t i = 0; i < mhash->table_size; i++) {
- myhtml_utils_mhash_entry_t *entry = table[i];
-
- while(entry) {
- myhtml_utils_mhash_rebuild_add_entry(mhash, entry->key, entry->key_length, entry);
-
- entry = entry->next;
- }
- }
-
- myhtml_free(table);
-
- return mhash->table;
-}
-
-
diff --git a/source/myhtml/utils/mhash.h b/source/myhtml/utils/mhash.h
deleted file mode 100644
index c3c8aec..0000000
--- a/source/myhtml/utils/mhash.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- Copyright (C) 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
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin avl_treet, Fifth Floor, Boston, MA 02110-1301 USA
-
- Author: lex.borisov@gmail.com (Alexander Borisov)
-*/
-
-#ifndef html_mhash_h
-#define html_mhash_h
-
-#include "myhtml/myosi.h"
-#include "myhtml/utils/mchar_async.h"
-
-typedef struct myhtml_utils_mhash_entry myhtml_utils_mhash_entry_t;
-
-struct myhtml_utils_mhash_entry {
- char* key;
- size_t key_length;
-
- void *value;
-
- myhtml_utils_mhash_entry_t* next;
-};
-
-struct myhtml_utils_mhash {
- mchar_async_t* mchar_obj;
- size_t mchar_node;
-
- myhtml_utils_mhash_entry_t** table;
- size_t table_size;
- size_t table_length;
-
- size_t table_max_depth;
-}
-typedef myhtml_utils_mhash_t;
-
-myhtml_utils_mhash_t * myhtml_utils_mhash_create(void);
-myhtml_status_t myhtml_utils_mhash_init(myhtml_utils_mhash_t* mhash, size_t table_size, size_t depth);
-void myhtml_utils_mhash_clean(myhtml_utils_mhash_t* mhash);
-myhtml_utils_mhash_t * myhtml_utils_mhash_destroy(myhtml_utils_mhash_t* mhash, bool self_destroy);
-myhtml_utils_mhash_entry_t * myhtml_utils_mhash_create_entry(myhtml_utils_mhash_t* mhash, const char* key, size_t key_size, void* value);
-
-myhtml_utils_mhash_entry_t * myhtml_utils_mhash_add(myhtml_utils_mhash_t* mhash, const char* key, size_t key_size, void* value);
-myhtml_utils_mhash_entry_t * myhtml_utils_mhash_search(myhtml_utils_mhash_t* mhash, const char* key, size_t key_size, void* value);
-myhtml_utils_mhash_entry_t * myhtml_utils_mhash_add_with_choice(myhtml_utils_mhash_t* mhash, const char* key, size_t key_size);
-
-myhtml_utils_mhash_entry_t * myhtml_utils_mhash_entry_by_id(myhtml_utils_mhash_t* mhash, size_t id);
-size_t myhtml_utils_mhash_get_table_size(myhtml_utils_mhash_t* mhash);
-
-myhtml_utils_mhash_entry_t ** myhtml_utils_mhash_rebuld(myhtml_utils_mhash_t* mhash);
-
-#endif
diff --git a/source/myhtml/utils/resources.h b/source/myhtml/utils/resources.h
deleted file mode 100644
index beee061..0000000
--- a/source/myhtml/utils/resources.h
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- Copyright (C) 2015-2016 Alexander Borisov
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
- Author: lex.borisov@gmail.com (Alexander Borisov)
-*/
-
-#ifndef MyHTML_UTILS_RESOURCES_H
-#define MyHTML_UTILS_RESOURCES_H
-#pragma once
-
-#include <stddef.h>
-
-#define MyHTML_TOKENIZER_CHAR_OTHER '\000'
-#define MyHTML_TOKENIZER_CHAR_A_Z_a_z '\001'
-#define MyHTML_TOKENIZER_CHAR_WHITESPACE '\002'
-
-static const unsigned char myhtml_string_chars_num_map[] = {
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
- 0x06, 0x07, 0x08, 0x09, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff
-};
-
-static const unsigned char myhtml_string_chars_hex_map[] = {
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
- 0x06, 0x07, 0x08, 0x09, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0a, 0x0b,
- 0x0c, 0x0d, 0x0e, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff
-};
-
-static const unsigned char myhtml_string_chars_lowercase_map[] = {
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
- 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11,
- 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a,
- 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
- 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c,
- 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35,
- 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e,
- 0x3f, 0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
- 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
- 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,
- 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62,
- 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b,
- 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74,
- 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d,
- 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86,
- 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
- 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
- 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1,
- 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa,
- 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3,
- 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc,
- 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5,
- 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce,
- 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
- 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0,
- 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,
- 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2,
- 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb,
- 0xfc, 0xfd, 0xfe, 0xff
-};
-
-static const size_t replacement_character[] = {
- 65533, 1, 2, 3, 4, 5, 6, 7, 8,
- 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 18, 19, 20, 21, 22, 23, 24, 25, 26,
- 27, 28, 29, 30, 31, 32, 33, 34, 35,
- 36, 37, 38, 39, 40, 41, 42, 43, 44,
- 45, 46, 47, 48, 49, 50, 51, 52, 53,
- 54, 55, 56, 57, 58, 59, 60, 61, 62,
- 63, 64, 65, 66, 67, 68, 69, 70, 71,
- 72, 73, 74, 75, 76, 77, 78, 79, 80,
- 81, 82, 83, 84, 85, 86, 87, 88, 89,
- 90, 91, 92, 93, 94, 95, 96, 97, 98,
- 99, 100, 101, 102, 103, 104, 105, 106, 107,
- 108, 109, 110, 111, 112, 113, 114, 115, 116,
- 117, 118, 119, 120, 121, 122, 123, 124, 125,
- 126, 127, 8364, 129, 8218, 402, 8222, 8230, 8224,
- 8225, 710, 8240, 352, 8249, 338, 141, 381, 143,
- 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 732,
- 8482, 353, 8250, 339, 157, 382, 376
-};
-
-static const size_t myhtml_string_alphanumeric_character[] = {
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
- 0x06, 0x07, 0x08, 0x09, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x0a,
- 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x0a, 0x0b, 0x0c, 0x0d,
- 0x0e, 0x0f, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x0a,
- 0x0b, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0c, 0x0d,
- 0x0e, 0x0f, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x0a,
- 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x0a, 0x0b, 0x0c, 0x0d,
- 0x0e, 0x0f, 0x0a, 0x0b, 0x0c, 0x0d, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff
-};
-
-static const unsigned char myhtml_tokenizer_chars_map[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00
-};
-
-static const unsigned char myhtml_string_hex_to_char_map[] = {
- 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
- 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x00
-};
-
-#endif /* MyHTML_UTILS_RESOURCES_H */