From 83f3338663c4969eebefd8c2c43bd3fc43587fdd Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Wed, 21 Dec 2011 22:18:10 +0000 Subject: Merge branches/jmb/dom-alloc-purge back to trunk svn path=/trunk/libdom/; revision=13316 --- src/utils/Makefile | 3 +- src/utils/hashtable.c | 169 +++++++++++++++-------------------------------- src/utils/hashtable.h | 44 +++++------- src/utils/namespace.c | 76 +++++++++++++-------- src/utils/namespace.h | 6 -- src/utils/resource_mgr.c | 104 ----------------------------- src/utils/resource_mgr.h | 43 ------------ 7 files changed, 119 insertions(+), 326 deletions(-) delete mode 100644 src/utils/resource_mgr.c delete mode 100644 src/utils/resource_mgr.h (limited to 'src/utils') diff --git a/src/utils/Makefile b/src/utils/Makefile index 428a9cf..1ab8bad 100644 --- a/src/utils/Makefile +++ b/src/utils/Makefile @@ -1,5 +1,4 @@ # Sources -DIR_SOURCES := namespace.c hashtable.c resource_mgr.c character_valid.c \ - validate.c +DIR_SOURCES := namespace.c hashtable.c character_valid.c validate.c include build/makefiles/Makefile.subdir diff --git a/src/utils/hashtable.c b/src/utils/hashtable.c index f1dc076..24cfd95 100644 --- a/src/utils/hashtable.c +++ b/src/utils/hashtable.c @@ -27,13 +27,11 @@ struct _dom_hash_entry { /* The hash table */ struct dom_hash_table { - unsigned int nchains; /**< The chains number */ - dom_hash_func hash; /**< The hash function */ + const dom_hash_vtable *vtable; /**< Vtable */ + void *pw; /**< Client data */ + unsigned int nchains; /**< Number of chains */ struct _dom_hash_entry **chain; /**< The chain head */ - unsigned int number; /**< The enries in this table */ - - dom_alloc alloc; /**< Memory allocation function */ - void *ptr; /**< The private data for the memory allocator */ + unsigned int nentries; /**< The entries in this table */ }; @@ -44,36 +42,26 @@ struct dom_hash_table { * \param chains Number of chains/buckets this hash table will have. This * should be a prime number, and ideally a prime number just * over a power of two, for best performance and distribution - * \param hash The hash function - * \param alloc The memory allocator - * \param ptr The private pointer for the allocator + * \param vtable Client vtable + * \param pw Client private data * \return struct dom_hash_table containing the context of this hash table or * NULL if there is insufficent memory to create it and its chains. */ -struct dom_hash_table *_dom_hash_create(unsigned int chains, dom_hash_func hash, - dom_alloc alloc, void *ptr) +dom_hash_table *_dom_hash_create(unsigned int chains, + const dom_hash_vtable *vtable, void *pw) { - struct dom_hash_table *r = alloc(NULL, sizeof(struct dom_hash_table), - ptr); - + dom_hash_table *r = malloc(sizeof(struct dom_hash_table)); if (r == NULL) { return NULL; } + r->vtable = vtable; + r->pw = pw; + r->nentries = 0; r->nchains = chains; - r->hash = hash; - r->alloc = alloc; - r->ptr = ptr; - r->chain = (struct _dom_hash_entry **)alloc(NULL, - chains*sizeof(struct _dom_hash_entry *), ptr); - r->number = 0; - - unsigned int i; - for (i = 0; i < chains; i++) - r->chain[i] = NULL; - + r->chain = calloc(chains, sizeof(struct _dom_hash_entry *)); if (r->chain == NULL) { - alloc(r, 0, ptr); + free(r); return NULL; } @@ -84,45 +72,37 @@ struct dom_hash_table *_dom_hash_create(unsigned int chains, dom_hash_func hash, * Clone a hash table. * * \param ht Hash table to clone. - * \param alloc The allocator. - * \param pw The private data for the allocator. - * \param kf The function pointer used to copy the key. - * \param key_pw The private data for the key cloner. - * \param vf The function pointer used to copy the value. - * \param value_pw The private data for the value cloner. * * \return The cloned hash table. */ -struct dom_hash_table *_dom_hash_clone(struct dom_hash_table *ht, - dom_alloc alloc, void *pw, dom_key_func kf, void *key_pw, - dom_value_func vf, void *value_pw) +dom_hash_table *_dom_hash_clone(dom_hash_table *ht) { + void *key = NULL, *nkey = NULL; + void *value = NULL, *nvalue = NULL; + uintptr_t c1, *c2 = NULL; struct dom_hash_table *ret; - ret = _dom_hash_create(ht->nchains, ht->hash, alloc, pw); + ret = _dom_hash_create(ht->nchains, ht->vtable, ht->pw); if (ret == NULL) return NULL; - void *key = NULL, *nkey = NULL; - void *value = NULL, *nvalue = NULL; - unsigned int c1, *c2 = NULL; while ( (key = _dom_hash_iterate(ht, &c1, &c2)) != NULL) { - nkey = kf(key, key_pw, alloc, pw, true); + nkey = ht->vtable->clone_key(key, ht->pw); if (nkey == NULL) { - _dom_hash_destroy(ret, kf, key_pw, vf, value_pw); + _dom_hash_destroy(ret); return NULL; } value = _dom_hash_get(ht, key); - nvalue = vf(value, value_pw, alloc, pw, true); + nvalue = ht->vtable->clone_value(value, ht->pw); if (nvalue == NULL) { - kf(nkey, key_pw, alloc, pw, false); - _dom_hash_destroy(ret, kf, key_pw, vf, value_pw); + ht->vtable->destroy_key(nkey, ht->pw); + _dom_hash_destroy(ret); return NULL; } if (_dom_hash_add(ret, nkey, nvalue, false) == false) { - _dom_hash_destroy(ret, kf, key_pw, vf, value_pw); + _dom_hash_destroy(ret); return NULL; } } @@ -135,42 +115,29 @@ struct dom_hash_table *_dom_hash_clone(struct dom_hash_table *ht, * * \param ht Hash table to destroy. After the function returns, this * will nolonger be valid - * \param kf The key destroy function - * \param key_pw The key destroy function private data - * \param vf The value destroy function - * \param value_pw The value destroy function private data */ -void _dom_hash_destroy(struct dom_hash_table *ht, dom_key_func kf, - void *key_pw, dom_value_func vf, void *value_pw) +void _dom_hash_destroy(dom_hash_table *ht) { unsigned int i; if (ht == NULL) return; - assert(ht->alloc != NULL); - for (i = 0; i < ht->nchains; i++) { if (ht->chain[i] != NULL) { struct _dom_hash_entry *e = ht->chain[i]; while (e) { struct _dom_hash_entry *n = e->next; - if (kf != NULL) { - kf(e->key, key_pw, ht->alloc, - ht->ptr, false); - } - if (vf != NULL) { - vf(e->value, value_pw, ht->alloc, - ht->ptr, false); - } - ht->alloc(e, 0, ht->ptr); + ht->vtable->destroy_key(e->key, ht->pw); + ht->vtable->destroy_value(e->value, ht->pw); + free(e); e = n; } } } - ht->alloc(ht->chain, 0, ht->ptr); - ht->alloc(ht, 0, ht->ptr); + free(ht->chain); + free(ht); } /** @@ -182,7 +149,7 @@ void _dom_hash_destroy(struct dom_hash_table *ht, dom_key_func kf, * \return true if the add succeeded, false otherwise. (Failure most likely * indicates insufficent memory to make copies of the key and value. */ -bool _dom_hash_add(struct dom_hash_table *ht, void *key, void *value, +bool _dom_hash_add(dom_hash_table *ht, void *key, void *value, bool replace) { unsigned int h, c; @@ -191,11 +158,11 @@ bool _dom_hash_add(struct dom_hash_table *ht, void *key, void *value, if (ht == NULL || key == NULL || value == NULL) return false; - h = ht->hash(key); + h = ht->vtable->hash(key, ht->pw); c = h % ht->nchains; - for (e = ht->chain[c]; e; e = e->next) - if (key == e->key) { + for (e = ht->chain[c]; e; e = e->next) { + if (ht->vtable->key_isequal(key, e->key, ht->pw)) { if (replace == true) { e->value = value; return true; @@ -203,10 +170,9 @@ bool _dom_hash_add(struct dom_hash_table *ht, void *key, void *value, return false; } } + } - assert(ht->alloc != NULL); - - e = ht->alloc(NULL, sizeof(struct _dom_hash_entry), ht->ptr); + e = malloc(sizeof(struct _dom_hash_entry)); if (e == NULL) { return false; } @@ -216,7 +182,7 @@ bool _dom_hash_add(struct dom_hash_table *ht, void *key, void *value, e->next = ht->chain[c]; ht->chain[c] = e; - ht->number ++; + ht->nentries++; return true; } @@ -236,12 +202,13 @@ void *_dom_hash_get(struct dom_hash_table *ht, void *key) if (ht == NULL || key == NULL) return NULL; - h = ht->hash(key); + h = ht->vtable->hash(key, ht->pw); c = h % ht->nchains; - for (e = ht->chain[c]; e; e = e->next) - if (key == e->key) + for (e = ht->chain[c]; e; e = e->next) { + if (ht->vtable->key_isequal(key, e->key, ht->pw)) return e->value; + } return NULL; } @@ -262,14 +229,12 @@ void *_dom_hash_del(struct dom_hash_table *ht, void *key) if (ht == NULL || key == NULL) return NULL; - h = ht->hash(key); + h = ht->vtable->hash(key, ht->pw); c = h % ht->nchains; - assert(ht->alloc != NULL); - p = ht->chain[c]; - for (e = p; e; p = e, e = e->next) - if (key == e->key) { + for (e = p; e; p = e, e = e->next) { + if (ht->vtable->key_isequal(key, e->key, ht->pw)) { if (p != e) { p->next = e->next; } else { @@ -278,10 +243,11 @@ void *_dom_hash_del(struct dom_hash_table *ht, void *key) } ret = e->value; - ht->alloc(e, 0, ht->ptr); - ht->number --; + free(e); + ht->nentries--; return ret; } + } return NULL; } @@ -294,10 +260,10 @@ void *_dom_hash_del(struct dom_hash_table *ht, void *key) * \param c2 Pointer to second context (set to 0 on first call) * \return The next hash key, or NULL for no more keys */ -void *_dom_hash_iterate(struct dom_hash_table *ht, unsigned int *c1, - unsigned int **c2) +void *_dom_hash_iterate(struct dom_hash_table *ht, uintptr_t *c1, + uintptr_t **c2) { - struct _dom_hash_entry **he = (struct _dom_hash_entry **)c2; + struct _dom_hash_entry **he = (struct _dom_hash_entry **) c2; if (ht == NULL) return NULL; @@ -328,41 +294,10 @@ void *_dom_hash_iterate(struct dom_hash_table *ht, unsigned int *c1, */ unsigned int _dom_hash_get_length(struct dom_hash_table *ht) { - return ht->number; -} - -/** - * Get the chain number of this hash table - * - * \param ht The hash table - * - * \return the number of chains - */ -unsigned int _dom_hash_get_chains(struct dom_hash_table *ht) -{ - return ht->nchains; -} - -/** - * Get the hash function of this hash table - * - * \param ht The hash table - * - * \return the hash function - */ -dom_hash_func _dom_hash_get_func(struct dom_hash_table *ht) -{ - return ht->hash; + return ht->nentries; } /*-----------------------------------------------------------------------*/ -/* The hash function for lwc_string type */ -unsigned int _dom_hash_hash_lwcstring(void *key) -{ - lwc_string *lstr = (lwc_string *) key; - - return lwc_string_hash_value(lstr); -} /* A simple test rig. To compile, use: * gcc -g -o hashtest -I../ -I../../include -DTEST_RIG hashtable.c diff --git a/src/utils/hashtable.h b/src/utils/hashtable.h index 625e440..27e1906 100644 --- a/src/utils/hashtable.h +++ b/src/utils/hashtable.h @@ -13,33 +13,25 @@ #include typedef struct dom_hash_table dom_hash_table; -/* The hash function */ -typedef unsigned int (*dom_hash_func)(void *key); -/* Function to clone/delete key */ -typedef void *(*dom_key_func)(void *key, void *pw, dom_alloc alloc, - void *alloc_pw, bool clone); -/* Function to clone/delete value */ -typedef void *(*dom_value_func)(void *value, void *pw, dom_alloc alloc, - void *alloc_pw, bool clone); -struct dom_hash_table *_dom_hash_create(unsigned int chains, dom_hash_func hash, - dom_alloc alloc, void *ptr); -struct dom_hash_table *_dom_hash_clone(struct dom_hash_table *ht, - dom_alloc alloc, void *pw, dom_key_func kf, void *key_pw, - dom_value_func vf, void *value_pw); -void _dom_hash_destroy(struct dom_hash_table *ht, dom_key_func kf, void *key_pw, - dom_value_func vf, void *value_pw); -bool _dom_hash_add(struct dom_hash_table *ht, void *key, void *value, - bool replace); -void *_dom_hash_get(struct dom_hash_table *ht, void *key); -void *_dom_hash_del(struct dom_hash_table *ht, void *key); -void *_dom_hash_iterate(struct dom_hash_table *ht, unsigned int *c1, - unsigned int **c2); -unsigned int _dom_hash_get_length(struct dom_hash_table *ht); -unsigned int _dom_hash_get_chains(struct dom_hash_table *ht); -dom_hash_func _dom_hash_get_func(struct dom_hash_table *ht); +typedef struct dom_hash_vtable { + uint32_t (*hash)(void *key, void *pw); + void *(*clone_key)(void *key, void *pw); + void (*destroy_key)(void *key, void *pw); + void *(*clone_value)(void *value, void *pw); + void (*destroy_value)(void *value, void *pw); + bool (*key_isequal)(void *key1, void *key2, void *pw); +} dom_hash_vtable; -/*-----------------------------------------------------------------------*/ -unsigned int _dom_hash_hash_lwcstring(void *key); +dom_hash_table *_dom_hash_create(unsigned int chains, + const dom_hash_vtable *vtable, void *pw); +dom_hash_table *_dom_hash_clone(dom_hash_table *ht); +void _dom_hash_destroy(dom_hash_table *ht); +bool _dom_hash_add(dom_hash_table *ht, void *key, void *value, + bool replace); +void *_dom_hash_get(dom_hash_table *ht, void *key); +void *_dom_hash_del(dom_hash_table *ht, void *key); +void *_dom_hash_iterate(dom_hash_table *ht, uintptr_t *c1, uintptr_t **c2); +uint32_t _dom_hash_get_length(dom_hash_table *ht); #endif diff --git a/src/utils/namespace.c b/src/utils/namespace.c index 2b14d72..2bc6318 100644 --- a/src/utils/namespace.c +++ b/src/utils/namespace.c @@ -38,23 +38,20 @@ dom_string *dom_namespaces[DOM_NAMESPACE_COUNT] = { /** * Initialise the namespace component * - * \param alloc Pointer to memory (de)allocation function - * \param pw Pointer to client-specific private data * \return DOM_NO_ERR on success. */ -dom_exception _dom_namespace_initialise(dom_alloc alloc, void *pw) +static dom_exception _dom_namespace_initialise(void) { int i; dom_exception err; - err = dom_string_create(alloc, pw, - (const uint8_t *) "xml", SLEN("xml"), &xml); + err = dom_string_create((const uint8_t *) "xml", SLEN("xml"), &xml); if (err != DOM_NO_ERR) { return err; } - err = dom_string_create(alloc, pw, - (const uint8_t *) "xmlns", SLEN("xmlns"), &xmlns); + err = dom_string_create((const uint8_t *) "xmlns", SLEN("xmlns"), + &xmlns); if (err != DOM_NO_ERR) { dom_string_unref(xml); xml = NULL; @@ -64,7 +61,7 @@ dom_exception _dom_namespace_initialise(dom_alloc alloc, void *pw) for (i = 1; i < DOM_NAMESPACE_COUNT; i++) { err = dom_string_create( - alloc, pw, (const uint8_t *) namespaces[i], + (const uint8_t *) namespaces[i], strlen(namespaces[i]), &dom_namespaces[i]); if (err != DOM_NO_ERR) { dom_string_unref(xmlns); @@ -80,6 +77,7 @@ dom_exception _dom_namespace_initialise(dom_alloc alloc, void *pw) return DOM_NO_ERR; } +#ifdef FINALISE_NAMESPACE /** * Finalise the namespace component * @@ -108,6 +106,7 @@ dom_exception _dom_namespace_finalise(void) return DOM_NO_ERR; } +#endif /** * Ensure a QName is valid @@ -134,7 +133,13 @@ dom_exception _dom_namespace_validate_qname(dom_string *qname, { uint32_t colon, len; - if (qname == NULL){ + if (xml == NULL) { + dom_exception err = _dom_namespace_initialise(); + if (err != DOM_NO_ERR) + return err; + } + + if (qname == NULL) { if (namespace != NULL) return DOM_NAMESPACE_ERR; if (namespace == NULL) @@ -153,16 +158,17 @@ dom_exception _dom_namespace_validate_qname(dom_string *qname, /* No prefix */ /* If namespace URI is for xmlns, ensure qname == "xmlns" */ if (namespace != NULL && - dom_string_cmp(namespace, - dom_namespaces[DOM_NAMESPACE_XMLNS]) == 0 && - dom_string_cmp(qname, xmlns) != 0) { + dom_string_isequal(namespace, + dom_namespaces[DOM_NAMESPACE_XMLNS]) && + dom_string_isequal(qname, xmlns) == false) { return DOM_NAMESPACE_ERR; } + /* If qname == "xmlns", ensure namespace URI is for xmlns */ if (namespace != NULL && - dom_string_cmp(qname, xmlns) == 0 && - dom_string_cmp(namespace, - dom_namespaces[DOM_NAMESPACE_XMLNS]) != 0) { + dom_string_isequal(qname, xmlns) && + dom_string_isequal(namespace, + dom_namespaces[DOM_NAMESPACE_XMLNS]) == false) { return DOM_NAMESPACE_ERR; } } else if (colon == 0) { @@ -196,25 +202,25 @@ dom_exception _dom_namespace_validate_qname(dom_string *qname, } /* Test for invalid XML namespace */ - if (dom_string_cmp(prefix, xml) == 0 && - dom_string_cmp(namespace, - dom_namespaces[DOM_NAMESPACE_XML]) != 0) { + if (dom_string_isequal(prefix, xml) && + dom_string_isequal(namespace, + dom_namespaces[DOM_NAMESPACE_XML]) == false) { dom_string_unref(prefix); return DOM_NAMESPACE_ERR; } /* Test for invalid xmlns namespace */ - if (dom_string_cmp(prefix, xmlns) == 0 && - dom_string_cmp(namespace, - dom_namespaces[DOM_NAMESPACE_XMLNS]) != 0) { + if (dom_string_isequal(prefix, xmlns) && + dom_string_isequal(namespace, + dom_namespaces[DOM_NAMESPACE_XMLNS]) == false) { dom_string_unref(prefix); return DOM_NAMESPACE_ERR; } /* Test for presence of xmlns namespace with non xmlns prefix */ - if (dom_string_cmp(namespace, - dom_namespaces[DOM_NAMESPACE_XMLNS]) == 0 && - dom_string_cmp(prefix, xmlns) != 0) { + if (dom_string_isequal(namespace, + dom_namespaces[DOM_NAMESPACE_XMLNS]) && + dom_string_isequal(prefix, xmlns) == false) { dom_string_unref(prefix); return DOM_NAMESPACE_ERR; } @@ -244,16 +250,19 @@ dom_exception _dom_namespace_split_qname(dom_string *qname, uint32_t colon; dom_exception err; + if (xml == NULL) { + err = _dom_namespace_initialise(); + if (err != DOM_NO_ERR) + return err; + } + /* Find colon, if any */ colon = dom_string_index(qname, ':'); if (colon == (uint32_t) -1) { /* None found => no prefix */ *prefix = NULL; - err = dom_string_dup(qname, localname); - if (err != DOM_NO_ERR) { - return err; - } + *localname = dom_string_ref(qname); } else { /* Found one => prefix */ err = dom_string_substr(qname, 0, colon, prefix); @@ -285,6 +294,11 @@ dom_exception _dom_namespace_split_qname(dom_string *qname, */ dom_string *_dom_namespace_get_xml_prefix(void) { + if (xml == NULL) { + if (_dom_namespace_initialise() != DOM_NO_ERR) + return NULL; + } + return xml; } @@ -300,5 +314,11 @@ dom_string *_dom_namespace_get_xml_prefix(void) */ dom_string *_dom_namespace_get_xmlns_prefix(void) { + if (xml == NULL) { + if (_dom_namespace_initialise() != DOM_NO_ERR) + return NULL; + } + return xmlns; } + diff --git a/src/utils/namespace.h b/src/utils/namespace.h index 221e9da..56be435 100644 --- a/src/utils/namespace.h +++ b/src/utils/namespace.h @@ -14,12 +14,6 @@ struct dom_document; -/* Initialise the namespace component */ -dom_exception _dom_namespace_initialise(dom_alloc alloc, void *pw); - -/* Finalise the namespace component */ -dom_exception _dom_namespace_finalise(void); - /* Ensure a QName is valid */ dom_exception _dom_namespace_validate_qname(dom_string *qname, dom_string *namespace); diff --git a/src/utils/resource_mgr.c b/src/utils/resource_mgr.c deleted file mode 100644 index ccaf015..0000000 --- a/src/utils/resource_mgr.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - * This file is part of libdom. - * Licensed under the MIT License, - * http://www.opensource.org/licenses/mit-license.php - * Copyright 2009 Bo Yang - */ - -#include "resource_mgr.h" - -#include -#include - -#include -#include "core/string.h" - -#include "utils/utils.h" - -/** - * Allocate some memory with this allocator - * - * \param res The resource manager - * \param size The size of memory to allocate - * \return the allocated memory pointer. - */ -void *_dom_resource_mgr_alloc(struct dom_resource_mgr *res, void *ptr, - size_t size) -{ - return res->alloc(ptr, size, res->pw); -} - -/** - * Create a dom_string using this resource manager - * - * \param res The resource manager - * \param data The data pointer - * \param len The length of data - * \param result The returned dom_string - * \return DOM_NO_ERR on success, appropriate dom_exception on failure. - */ -dom_exception _dom_resource_mgr_create_string(struct dom_resource_mgr *res, - const uint8_t *data, size_t len, dom_string **result) -{ - return dom_string_create(res->alloc, res->pw, data, len, result); -} - -/** - * Create a lwc_string using this resource manager - * - * \param res The resource manager - * \param data The data pointer - * \param len The length of the data - * \param result The returned lwc_string - * \return DOM_NO_ERR on success, appropriate dom_exception on failure. - */ -dom_exception _dom_resource_mgr_create_lwcstring(struct dom_resource_mgr *res, - const uint8_t *data, size_t len, struct lwc_string_s **result) -{ - lwc_error lerr; - - UNUSED(res); - - lerr = lwc_intern_string((const char *) data, len, result); - - return _dom_exception_from_lwc_error(lerr); -} - -/** - * Create a dom_string from a lwc_string using this resource manager - * - * \param res The resource manager - * \param str The dom_string to intern - * \param result The returned lwc_string - * \return DOM_NO_ERR on success, appropriate dom_exception on failure. - */ -dom_exception _dom_resource_mgr_create_string_from_lwcstring( - struct dom_resource_mgr *res, struct lwc_string_s *str, - dom_string **result) -{ - return _dom_string_create_from_lwcstring(res->alloc, res->pw, - str, result); -} - -/** - * Create a hash table using this resource manager - * - * \param res The resource manager - * \param chains The number of buckets of the hash table - * \param f The hash function - * \param ht The returned hash table - * \return DOM_NO_ERR on success, appropriate dom_exception on failure. - */ -dom_exception _dom_resource_mgr_create_hashtable(struct dom_resource_mgr *res, - size_t chains, dom_hash_func f, struct dom_hash_table **ht) -{ - struct dom_hash_table *ret; - - ret = _dom_hash_create(chains, f, res->alloc, res->pw); - if (ret == NULL) - return DOM_NO_MEM_ERR; - - *ht = ret; - return DOM_NO_ERR; -} - diff --git a/src/utils/resource_mgr.h b/src/utils/resource_mgr.h deleted file mode 100644 index 1b604ec..0000000 --- a/src/utils/resource_mgr.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * This file is part of libdom. - * Licensed under the MIT License, - * http://www.opensource.org/licenses/mit-license.php - * Copyright 2009 Bo Yang - */ - -#ifndef dom_utils_resource_mgr_h_ -#define dom_utils_resource_mgr_h_ - -#include -#include -#include - -#include "hashtable.h" - -struct lwc_string_s; - -/** - * Resource manager - */ -typedef struct dom_resource_mgr { - dom_alloc alloc; - void *pw; -} dom_resource_mgr; - -void *_dom_resource_mgr_alloc(struct dom_resource_mgr *res, void *ptr, - size_t size); - -dom_exception _dom_resource_mgr_create_string(struct dom_resource_mgr *res, - const uint8_t *data, size_t len, dom_string **result); - -dom_exception _dom_resource_mgr_create_lwcstring(struct dom_resource_mgr *res, - const uint8_t *data, size_t len, struct lwc_string_s **result); - -dom_exception _dom_resource_mgr_create_string_from_lwcstring( - struct dom_resource_mgr *res, struct lwc_string_s *str, - dom_string **result); - -dom_exception _dom_resource_mgr_create_hashtable(struct dom_resource_mgr *res, - size_t chains, dom_hash_func f, struct dom_hash_table **ht); - -#endif -- cgit v1.2.3