ReactOS 0.4.16-dev-2132-g3885311
dict.h File Reference
#include <stddef.h>
#include <libxml/xmlversion.h>
#include <libxml/xmlstring.h>
Include dependency graph for dict.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef struct _xmlDict xmlDict
 
typedef xmlDictxmlDictPtr
 

Functions

XML_DEPRECATED XMLPUBFUN int xmlInitializeDict (void)
 
XMLPUBFUN xmlDictPtr xmlDictCreate (void)
 
XMLPUBFUN size_t xmlDictSetLimit (xmlDictPtr dict, size_t limit)
 
XMLPUBFUN size_t xmlDictGetUsage (xmlDictPtr dict)
 
XMLPUBFUN xmlDictPtr xmlDictCreateSub (xmlDictPtr sub)
 
XMLPUBFUN int xmlDictReference (xmlDictPtr dict)
 
XMLPUBFUN void xmlDictFree (xmlDictPtr dict)
 
XMLPUBFUN const xmlCharxmlDictLookup (xmlDictPtr dict, const xmlChar *name, int len)
 
XMLPUBFUN const xmlCharxmlDictExists (xmlDictPtr dict, const xmlChar *name, int len)
 
XMLPUBFUN const xmlCharxmlDictQLookup (xmlDictPtr dict, const xmlChar *prefix, const xmlChar *name)
 
XMLPUBFUN int xmlDictOwns (xmlDictPtr dict, const xmlChar *str)
 
XMLPUBFUN int xmlDictSize (xmlDictPtr dict)
 
XML_DEPRECATED XMLPUBFUN void xmlDictCleanup (void)
 

Typedef Documentation

◆ xmlDict

Definition at line 25 of file dict.h.

◆ xmlDictPtr

typedef xmlDict* xmlDictPtr

Definition at line 26 of file dict.h.

Function Documentation

◆ xmlDictCleanup()

XML_DEPRECATED XMLPUBFUN void xmlDictCleanup ( void  )

xmlDictCleanup:

DEPRECATED: This function is a no-op. Call xmlCleanupParser to free global state but see the warnings there. xmlCleanupParser should be only called once at program exit. In most cases, you don't have call cleanup functions at all.

Definition at line 112 of file dict.c.

112 {
113}

◆ xmlDictCreate()

XMLPUBFUN xmlDictPtr xmlDictCreate ( void  )

xmlDictCreate:

Create a new dictionary

Returns the newly created dictionary, or NULL if an error occurred.

Definition at line 262 of file dict.c.

262 {
263 xmlDictPtr dict;
264
266
267 dict = xmlMalloc(sizeof(xmlDict));
268 if (dict == NULL)
269 return(NULL);
270 dict->ref_counter = 1;
271 dict->limit = 0;
272
273 dict->size = 0;
274 dict->nbElems = 0;
275 dict->table = NULL;
276 dict->strings = NULL;
277 dict->subdict = NULL;
278 dict->seed = xmlRandom();
279#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
280 dict->seed = 0;
281#endif
282 return(dict);
283}
#define NULL
Definition: types.h:112
unsigned xmlRandom(void)
Definition: dict.c:951
xmlMallocFunc xmlMalloc
Definition: globals.c:193
XML_GLOBALS_PARSER XMLPUBFUN void xmlInitParser(void)
Definition: threads.c:569
Definition: dict.c:59
unsigned seed
Definition: dict.c:69
size_t limit
Definition: dict.c:71
xmlDictStringsPtr strings
Definition: dict.c:65
struct _xmlDict * subdict
Definition: dict.c:67
int ref_counter
Definition: dict.c:60
unsigned int nbElems
Definition: dict.c:64
size_t size
Definition: dict.c:63
xmlDictEntry * table
Definition: dict.c:62

Referenced by xmlDictCreateSub(), xmlInitSAXParserCtxt(), and xsltNewStylesheetInternal().

◆ xmlDictCreateSub()

XMLPUBFUN xmlDictPtr xmlDictCreateSub ( xmlDictPtr  sub)

xmlDictCreateSub: @sub: an existing dictionary

Create a new dictionary, inheriting strings from the read-only dictionary @sub. On lookup, strings are first searched in the new dictionary, then in @sub, and if not found are created in the new dictionary.

Returns the newly created dictionary, or NULL if an error occurred.

Definition at line 297 of file dict.c.

297 {
298 xmlDictPtr dict = xmlDictCreate();
299
300 if ((dict != NULL) && (sub != NULL)) {
301 dict->seed = sub->seed;
302 dict->subdict = sub;
304 }
305 return(dict);
306}
int xmlDictReference(xmlDictPtr dict)
Definition: dict.c:317
xmlDictPtr xmlDictCreate(void)
Definition: dict.c:262

Referenced by xsltNewTransformContext().

◆ xmlDictExists()

XMLPUBFUN const xmlChar * xmlDictExists ( xmlDictPtr  dict,
const xmlChar name,
int  len 
)

Definition at line 872 of file dict.c.

872 {
873 const xmlDictEntry *entry;
874
876 if (entry == NULL)
877 return(NULL);
878 return(entry->name);
879}
GLenum GLsizei len
Definition: glext.h:6722
uint32_t entry
Definition: isohybrid.c:63
static ATTRIBUTE_NO_SANITIZE_INTEGER const xmlDictEntry * xmlDictLookupInternal(xmlDictPtr dict, const xmlChar *prefix, const xmlChar *name, int maybeLen, int update)
Definition: dict.c:678
Definition: name.c:39

◆ xmlDictFree()

XMLPUBFUN void xmlDictFree ( xmlDictPtr  dict)

xmlDictFree: @dict: the dictionary

Free the hash @dict and its contents. The userdata is deallocated with @f if provided.

Definition at line 333 of file dict.c.

333 {
334 xmlDictStringsPtr pool, nextp;
335
336 if (dict == NULL)
337 return;
338
339 /* decrement the counter, it may be shared by a parser and docs */
341 dict->ref_counter--;
342 if (dict->ref_counter > 0) {
344 return;
345 }
346
348
349 if (dict->subdict != NULL) {
350 xmlDictFree(dict->subdict);
351 }
352
353 if (dict->table) {
354 xmlFree(dict->table);
355 }
356 pool = dict->strings;
357 while (pool != NULL) {
358 nextp = pool->next;
359 xmlFree(pool);
360 pool = nextp;
361 }
362 xmlFree(dict);
363}
XMLPUBFUN void xmlMutexLock(xmlMutexPtr tok)
Definition: threads.c:201
XMLPUBFUN void xmlMutexUnlock(xmlMutexPtr tok)
Definition: threads.c:225
void xmlDictFree(xmlDictPtr dict)
Definition: dict.c:333
static xmlMutex xmlDictMutex
Definition: dict.c:78
xmlFreeFunc xmlFree
Definition: globals.c:184

Referenced by xmlDictFree(), xmlFreeParserCtxt(), xmlHashFree(), xmlParseBalancedChunkMemoryInternal(), xmlParseExternalEntityPrivate(), xmlParseInNodeContext(), xslt_doc_default_loader(), xsltDocDefaultLoaderFunc(), xsltFreeStylesheet(), xsltFreeTransformContext(), and xsltParseStylesheetUser().

◆ xmlDictGetUsage()

XMLPUBFUN size_t xmlDictGetUsage ( xmlDictPtr  dict)

xmlDictGetUsage: @dict: the dictionary

Get how much memory is used by a dictionary for strings Added in 2.9.0

Returns the amount of strings allocated

Definition at line 441 of file dict.c.

441 {
443 size_t limit = 0;
444
445 if (dict == NULL)
446 return(0);
447 pool = dict->strings;
448 while (pool != NULL) {
449 limit += pool->size;
450 pool = pool->next;
451 }
452 return(limit);
453}
GLint limit
Definition: glext.h:10326

◆ xmlDictLookup()

◆ xmlDictOwns()

XMLPUBFUN int xmlDictOwns ( xmlDictPtr  dict,
const xmlChar str 
)

xmlDictOwns: @dict: the dictionary @str: the string

check if a string is owned by the dictionary

Returns 1 if true, 0 if false and -1 in case of error -1 in case of error

Definition at line 376 of file dict.c.

376 {
378
379 if ((dict == NULL) || (str == NULL))
380 return(-1);
381 pool = dict->strings;
382 while (pool != NULL) {
383 if ((str >= &pool->array[0]) && (str <= pool->free))
384 return(1);
385 pool = pool->next;
386 }
387 if (dict->subdict)
388 return(xmlDictOwns(dict->subdict, str));
389 return(0);
390}
#define free
Definition: debug_ros.c:5
const WCHAR * str
int xmlDictOwns(xmlDictPtr dict, const xmlChar *str)
Definition: dict.c:376

Referenced by xmlDictOwns(), xmlFreeAttribute(), xmlFreeDocElementContent(), xmlHashUpdateInternal(), xmlParseEnumerationType(), xmlParseNotationType(), xmlSAX2ExternalSubset(), xmlSAX2Text(), xsltAttrListTemplateProcess(), xsltAttrTemplateProcess(), xsltCopyText(), xsltParseTemplateContent(), and xsltPreprocessStylesheet().

◆ xmlDictQLookup()

XMLPUBFUN const xmlChar * xmlDictQLookup ( xmlDictPtr  dict,
const xmlChar prefix,
const xmlChar name 
)

Definition at line 894 of file dict.c.

894 {
895 const xmlDictEntry *entry;
896
897 entry = xmlDictLookupInternal(dict, prefix, name, -1, 1);
898 if (entry == NULL)
899 return(NULL);
900 return(entry->name);
901}
Character const *const prefix
Definition: tempnam.cpp:195

Referenced by xmlSAX2StartElementNs(), xsltApplyStylesheetInternal(), and xsltDocumentElem().

◆ xmlDictReference()

XMLPUBFUN int xmlDictReference ( xmlDictPtr  dict)

xmlDictReference: @dict: the dictionary

Increment the reference counter of a dictionary

Returns 0 in case of success and -1 in case of error

Definition at line 317 of file dict.c.

317 {
318 if (dict == NULL) return -1;
320 dict->ref_counter++;
322 return(0);
323}

Referenced by xmlDictCreateSub(), xmlHashCreateDict(), xmlParseBalancedChunkMemoryInternal(), xmlParseExternalEntityPrivate(), xmlSAX2StartDocument(), xslt_doc_default_loader(), xsltApplyStylesheetInternal(), xsltCreateRVT(), xsltDocDefaultLoaderFunc(), xsltDocumentElem(), xsltLoadStylesheetPI(), and xsltParseStylesheetUser().

◆ xmlDictSetLimit()

XMLPUBFUN size_t xmlDictSetLimit ( xmlDictPtr  dict,
size_t  limit 
)

xmlDictSetLimit: @dict: the dictionary @limit: the limit in bytes

Set a size limit for the dictionary Added in 2.9.0

Returns the previous limit of the dictionary or 0

Definition at line 421 of file dict.c.

421 {
422 size_t ret;
423
424 if (dict == NULL)
425 return(0);
426 ret = dict->limit;
427 dict->limit = limit;
428 return(ret);
429}
return ret
Definition: mutex.c:146

Referenced by xmlCtxtUseOptionsInternal(), and xmlInitSAXParserCtxt().

◆ xmlDictSize()

XMLPUBFUN int xmlDictSize ( xmlDictPtr  dict)

xmlDictSize: @dict: the dictionary

Query the number of elements installed in the hash @dict.

Returns the number of elements in the dictionary or -1 in case of error

Definition at line 402 of file dict.c.

402 {
403 if (dict == NULL)
404 return(-1);
405 if (dict->subdict)
406 return(dict->nbElems + dict->subdict->nbElems);
407 return(dict->nbElems);
408}

◆ xmlInitializeDict()

XML_DEPRECATED XMLPUBFUN int xmlInitializeDict ( void  )

xmlInitializeDict:

DEPRECATED: Alias for xmlInitParser.

Returns 0.

Definition at line 88 of file dict.c.

88 {
90 return(0);
91}