ReactOS  0.4.13-dev-259-g5ca9c9c
dict.h File Reference
#include <limits.h>
#include <libxml/xmlversion.h>
#include <libxml/tree.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.

Macros

#define __XML_EXTERNC
 

Typedefs

typedef typedef__XML_EXTERNC struct _xmlDict xmlDict
 

Functions

XMLPUBFUN int XMLCALL xmlInitializeDict (void)
 
XMLPUBFUN xmlDictPtr XMLCALL xmlDictCreate (void)
 
XMLPUBFUN size_t XMLCALL xmlDictSetLimit (xmlDictPtr dict, size_t limit)
 
XMLPUBFUN size_t XMLCALL xmlDictGetUsage (xmlDictPtr dict)
 
XMLPUBFUN xmlDictPtr XMLCALL xmlDictCreateSub (xmlDictPtr sub)
 
XMLPUBFUN int XMLCALL xmlDictReference (xmlDictPtr dict)
 
XMLPUBFUN void XMLCALL xmlDictFree (xmlDictPtr dict)
 
XMLPUBFUN const xmlChar *XMLCALL xmlDictLookup (xmlDictPtr dict, const xmlChar *name, int len)
 
XMLPUBFUN const xmlChar *XMLCALL xmlDictExists (xmlDictPtr dict, const xmlChar *name, int len)
 
XMLPUBFUN const xmlChar *XMLCALL xmlDictQLookup (xmlDictPtr dict, const xmlChar *prefix, const xmlChar *name)
 
XMLPUBFUN int XMLCALL xmlDictOwns (xmlDictPtr dict, const xmlChar *str)
 
XMLPUBFUN int XMLCALL xmlDictSize (xmlDictPtr dict)
 
XMLPUBFUN void XMLCALL xmlDictCleanup (void)
 

Variables

__XML_EXTERNC typedef xmlDictxmlDictPtr
 

Macro Definition Documentation

◆ __XML_EXTERNC

#define __XML_EXTERNC

Definition at line 17 of file dict.h.

Typedef Documentation

◆ xmlDict

typedef typedef__XML_EXTERNC struct _xmlDict xmlDict

Definition at line 23 of file dict.h.

Function Documentation

◆ xmlDictCleanup()

XMLPUBFUN void XMLCALL xmlDictCleanup ( void  )

xmlDictCleanup:

Free the dictionary mutex. Do not call unless sure the library is not in use anymore !

Definition at line 221 of file dict.c.

221  {
222  if (!xmlDictInitialized)
223  return;
224 
226 
227  xmlDictInitialized = 0;
228 }
static int xmlDictInitialized
Definition: dict.c:139
static xmlRMutexPtr xmlDictMutex
Definition: dict.c:134
XMLPUBFUN void XMLCALL xmlFreeRMutex(xmlRMutexPtr tok)
Definition: threads.c:319

Referenced by xmlCleanupParser().

◆ xmlDictCreate()

XMLPUBFUN xmlDictPtr XMLCALL xmlDictCreate ( void  )

xmlDictCreate:

Create a new dictionary

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

Definition at line 568 of file dict.c.

568  {
569  xmlDictPtr dict;
570 
571  if (!xmlDictInitialized)
572  if (!__xmlInitializeDict())
573  return(NULL);
574 
575 #ifdef DICT_DEBUG_PATTERNS
576  fprintf(stderr, "C");
577 #endif
578 
579  dict = xmlMalloc(sizeof(xmlDict));
580  if (dict) {
581  dict->ref_counter = 1;
582  dict->limit = 0;
583 
584  dict->size = MIN_DICT_SIZE;
585  dict->nbElems = 0;
586  dict->dict = xmlMalloc(MIN_DICT_SIZE * sizeof(xmlDictEntry));
587  dict->strings = NULL;
588  dict->subdict = NULL;
589  if (dict->dict) {
590  memset(dict->dict, 0, MIN_DICT_SIZE * sizeof(xmlDictEntry));
591 #ifdef DICT_RANDOMIZATION
592  dict->seed = __xmlRandom();
593 #else
594  dict->seed = 0;
595 #endif
596  return(dict);
597  }
598  xmlFree(dict);
599  }
600  return(NULL);
601 }
static int xmlDictInitialized
Definition: dict.c:139
int __xmlRandom(void)
Definition: dict.c:197
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
smooth NULL
Definition: ftsmooth.c:416
int __xmlInitializeDict(void)
Definition: dict.c:175
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
#define MIN_DICT_SIZE
Definition: dict.c:65
__XML_EXTERNC typedef xmlDict * xmlDictPtr
Definition: dict.h:24
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
typedef__XML_EXTERNC struct _xmlDict xmlDict
Definition: dict.h:23
FILE * stderr
#define memset(x, y, z)
Definition: compat.h:39

Referenced by xmlDictCreateSub(), xmlInitParserCtxt(), and xsltNewStylesheet().

◆ xmlDictCreateSub()

XMLPUBFUN xmlDictPtr XMLCALL 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 615 of file dict.c.

615  {
616  xmlDictPtr dict = xmlDictCreate();
617 
618  if ((dict != NULL) && (sub != NULL)) {
619 #ifdef DICT_DEBUG_PATTERNS
620  fprintf(stderr, "R");
621 #endif
622  dict->seed = sub->seed;
623  dict->subdict = sub;
624  xmlDictReference(dict->subdict);
625  }
626  return(dict);
627 }
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
xmlDictPtr xmlDictCreate(void)
Definition: dict.c:568
smooth NULL
Definition: ftsmooth.c:416
__XML_EXTERNC typedef xmlDict * xmlDictPtr
Definition: dict.h:24
FILE * stderr
int xmlDictReference(xmlDictPtr dict)
Definition: dict.c:638

Referenced by xsltNewTransformContext().

◆ xmlDictExists()

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

Definition at line 998 of file dict.c.

998  {
999  unsigned long key, okey, nbi = 0;
1001  unsigned int l;
1002 
1003  if ((dict == NULL) || (name == NULL))
1004  return(NULL);
1005 
1006  if (len < 0)
1007  l = strlen((const char *) name);
1008  else
1009  l = len;
1010  if (((dict->limit > 0) && (l >= dict->limit)) ||
1011  (l > INT_MAX / 2))
1012  return(NULL);
1013 
1014  /*
1015  * Check for duplicate and insertion location.
1016  */
1017  okey = xmlDictComputeKey(dict, name, l);
1018  key = okey % dict->size;
1019  if (dict->dict[key].valid == 0) {
1020  insert = NULL;
1021  } else {
1022  for (insert = &(dict->dict[key]); insert->next != NULL;
1023  insert = insert->next) {
1024 #ifdef __GNUC__
1025  if ((insert->okey == okey) && (insert->len == l)) {
1026  if (!memcmp(insert->name, name, l))
1027  return(insert->name);
1028  }
1029 #else
1030  if ((insert->okey == okey) && (insert->len == l) &&
1031  (!xmlStrncmp(insert->name, name, l)))
1032  return(insert->name);
1033 #endif
1034  nbi++;
1035  }
1036 #ifdef __GNUC__
1037  if ((insert->okey == okey) && (insert->len == l)) {
1038  if (!memcmp(insert->name, name, l))
1039  return(insert->name);
1040  }
1041 #else
1042  if ((insert->okey == okey) && (insert->len == l) &&
1043  (!xmlStrncmp(insert->name, name, l)))
1044  return(insert->name);
1045 #endif
1046  }
1047 
1048  if (dict->subdict) {
1049  unsigned long skey;
1050 
1051  /* we cannot always reuse the same okey for the subdict */
1052  if (((dict->size == MIN_DICT_SIZE) &&
1053  (dict->subdict->size != MIN_DICT_SIZE)) ||
1054  ((dict->size != MIN_DICT_SIZE) &&
1055  (dict->subdict->size == MIN_DICT_SIZE)))
1056  skey = xmlDictComputeKey(dict->subdict, name, l);
1057  else
1058  skey = okey;
1059 
1060  key = skey % dict->subdict->size;
1061  if (dict->subdict->dict[key].valid != 0) {
1062  xmlDictEntryPtr tmp;
1063 
1064  for (tmp = &(dict->subdict->dict[key]); tmp->next != NULL;
1065  tmp = tmp->next) {
1066 #ifdef __GNUC__
1067  if ((tmp->okey == skey) && (tmp->len == l)) {
1068  if (!memcmp(tmp->name, name, l))
1069  return(tmp->name);
1070  }
1071 #else
1072  if ((tmp->okey == skey) && (tmp->len == l) &&
1073  (!xmlStrncmp(tmp->name, name, l)))
1074  return(tmp->name);
1075 #endif
1076  nbi++;
1077  }
1078 #ifdef __GNUC__
1079  if ((tmp->okey == skey) && (tmp->len == l)) {
1080  if (!memcmp(tmp->name, name, l))
1081  return(tmp->name);
1082  }
1083 #else
1084  if ((tmp->okey == skey) && (tmp->len == l) &&
1085  (!xmlStrncmp(tmp->name, name, l)))
1086  return(tmp->name);
1087 #endif
1088  }
1089  }
1090 
1091  /* not found */
1092  return(NULL);
1093 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define INT_MAX
Definition: limits.h:40
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static int insert
Definition: xmllint.c:144
smooth NULL
Definition: ftsmooth.c:416
r l[0]
Definition: byte_order.h:167
struct _xmlDictEntry * next
Definition: dict.c:95
HKEY key
Definition: reg.c:42
GLenum GLsizei len
Definition: glext.h:6722
XMLPUBFUN int XMLCALL xmlStrncmp(const xmlChar *str1, const xmlChar *str2, int len)
Definition: xmlstring.c:206
#define MIN_DICT_SIZE
Definition: dict.c:65
unsigned int len
Definition: dict.c:97
Definition: name.c:36
const xmlChar * name
Definition: dict.c:96
#define xmlDictComputeKey(dict, name, len)
Definition: dict.c:70
unsigned long okey
Definition: dict.c:99
Definition: path.c:42

◆ xmlDictFree()

XMLPUBFUN void XMLCALL 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 793 of file dict.c.

793  {
794  size_t i;
795  xmlDictEntryPtr iter;
797  int inside_dict = 0;
798  xmlDictStringsPtr pool, nextp;
799 
800  if (dict == NULL)
801  return;
802 
803  if (!xmlDictInitialized)
804  if (!__xmlInitializeDict())
805  return;
806 
807  /* decrement the counter, it may be shared by a parser and docs */
809  dict->ref_counter--;
810  if (dict->ref_counter > 0) {
812  return;
813  }
814 
816 
817  if (dict->subdict != NULL) {
818  xmlDictFree(dict->subdict);
819  }
820 
821  if (dict->dict) {
822  for(i = 0; ((i < dict->size) && (dict->nbElems > 0)); i++) {
823  iter = &(dict->dict[i]);
824  if (iter->valid == 0)
825  continue;
826  inside_dict = 1;
827  while (iter) {
828  next = iter->next;
829  if (!inside_dict)
830  xmlFree(iter);
831  dict->nbElems--;
832  inside_dict = 0;
833  iter = next;
834  }
835  }
836  xmlFree(dict->dict);
837  }
838  pool = dict->strings;
839  while (pool != NULL) {
840  nextp = pool->next;
841  xmlFree(pool);
842  pool = nextp;
843  }
844  xmlFree(dict);
845 }
int valid
Definition: dict.c:98
XMLPUBFUN void XMLCALL xmlRMutexLock(xmlRMutexPtr tok)
Definition: threads.c:343
static int xmlDictInitialized
Definition: dict.c:139
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
void xmlDictFree(xmlDictPtr dict)
Definition: dict.c:793
smooth NULL
Definition: ftsmooth.c:416
static xmlRMutexPtr xmlDictMutex
Definition: dict.c:134
int __xmlInitializeDict(void)
Definition: dict.c:175
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
XMLPUBFUN void XMLCALL xmlRMutexUnlock(xmlRMutexPtr tok)
Definition: threads.c:388
struct _xmlDictEntry * next
Definition: dict.c:95
static unsigned __int64 next
Definition: rand_nt.c:6

Referenced by xmlFreeParserCtxt(), xmlHashFree(), xmlParseBalancedChunkMemoryInternal(), xmlParseCtxtExternalEntity(), xmlParseInNodeContext(), xsltDocDefaultLoaderFunc(), xsltFreeStylesheet(), xsltFreeTransformContext(), and xsltParseStylesheetImportedDoc().

◆ xmlDictGetUsage()

XMLPUBFUN size_t XMLCALL 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 1276 of file dict.c.

1276  {
1278  size_t limit = 0;
1279 
1280  if (dict == NULL)
1281  return(0);
1282  pool = dict->strings;
1283  while (pool != NULL) {
1284  limit += pool->size;
1285  pool = pool->next;
1286  }
1287  return(limit);
1288 }
GLint limit
Definition: glext.h:10326
smooth NULL
Definition: ftsmooth.c:416

◆ xmlDictLookup()

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

Definition at line 858 of file dict.c.

858  {
859  unsigned long key, okey, nbi = 0;
862  const xmlChar *ret;
863  unsigned int l;
864 
865  if ((dict == NULL) || (name == NULL))
866  return(NULL);
867 
868  if (len < 0)
869  l = strlen((const char *) name);
870  else
871  l = len;
872 
873  if (((dict->limit > 0) && (l >= dict->limit)) ||
874  (l > INT_MAX / 2))
875  return(NULL);
876 
877  /*
878  * Check for duplicate and insertion location.
879  */
880  okey = xmlDictComputeKey(dict, name, l);
881  key = okey % dict->size;
882  if (dict->dict[key].valid == 0) {
883  insert = NULL;
884  } else {
885  for (insert = &(dict->dict[key]); insert->next != NULL;
886  insert = insert->next) {
887 #ifdef __GNUC__
888  if ((insert->okey == okey) && (insert->len == l)) {
889  if (!memcmp(insert->name, name, l))
890  return(insert->name);
891  }
892 #else
893  if ((insert->okey == okey) && (insert->len == l) &&
894  (!xmlStrncmp(insert->name, name, l)))
895  return(insert->name);
896 #endif
897  nbi++;
898  }
899 #ifdef __GNUC__
900  if ((insert->okey == okey) && (insert->len == l)) {
901  if (!memcmp(insert->name, name, l))
902  return(insert->name);
903  }
904 #else
905  if ((insert->okey == okey) && (insert->len == l) &&
906  (!xmlStrncmp(insert->name, name, l)))
907  return(insert->name);
908 #endif
909  }
910 
911  if (dict->subdict) {
912  unsigned long skey;
913 
914  /* we cannot always reuse the same okey for the subdict */
915  if (((dict->size == MIN_DICT_SIZE) &&
916  (dict->subdict->size != MIN_DICT_SIZE)) ||
917  ((dict->size != MIN_DICT_SIZE) &&
918  (dict->subdict->size == MIN_DICT_SIZE)))
919  skey = xmlDictComputeKey(dict->subdict, name, l);
920  else
921  skey = okey;
922 
923  key = skey % dict->subdict->size;
924  if (dict->subdict->dict[key].valid != 0) {
925  xmlDictEntryPtr tmp;
926 
927  for (tmp = &(dict->subdict->dict[key]); tmp->next != NULL;
928  tmp = tmp->next) {
929 #ifdef __GNUC__
930  if ((tmp->okey == skey) && (tmp->len == l)) {
931  if (!memcmp(tmp->name, name, l))
932  return(tmp->name);
933  }
934 #else
935  if ((tmp->okey == skey) && (tmp->len == l) &&
936  (!xmlStrncmp(tmp->name, name, l)))
937  return(tmp->name);
938 #endif
939  nbi++;
940  }
941 #ifdef __GNUC__
942  if ((tmp->okey == skey) && (tmp->len == l)) {
943  if (!memcmp(tmp->name, name, l))
944  return(tmp->name);
945  }
946 #else
947  if ((tmp->okey == skey) && (tmp->len == l) &&
948  (!xmlStrncmp(tmp->name, name, l)))
949  return(tmp->name);
950 #endif
951  }
952  key = okey % dict->size;
953  }
954 
955  ret = xmlDictAddString(dict, name, l);
956  if (ret == NULL)
957  return(NULL);
958  if (insert == NULL) {
959  entry = &(dict->dict[key]);
960  } else {
961  entry = xmlMalloc(sizeof(xmlDictEntry));
962  if (entry == NULL)
963  return(NULL);
964  }
965  entry->name = ret;
966  entry->len = l;
967  entry->next = NULL;
968  entry->valid = 1;
969  entry->okey = okey;
970 
971 
972  if (insert != NULL)
973  insert->next = entry;
974 
975  dict->nbElems++;
976 
977  if ((nbi > MAX_HASH_LEN) &&
978  (dict->size <= ((MAX_DICT_HASH / 2) / MAX_HASH_LEN))) {
979  if (xmlDictGrow(dict, MAX_HASH_LEN * 2 * dict->size) != 0)
980  return(NULL);
981  }
982  /* Note that entry may have been freed at this point by xmlDictGrow */
983 
984  return(ret);
985 }
static int xmlDictGrow(xmlDictPtr dict, size_t size)
Definition: dict.c:660
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define INT_MAX
Definition: limits.h:40
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define MAX_DICT_HASH
Definition: dict.c:66
static int insert
Definition: xmllint.c:144
smooth NULL
Definition: ftsmooth.c:416
r l[0]
Definition: byte_order.h:167
int ret
struct _xmlDictEntry * next
Definition: dict.c:95
HKEY key
Definition: reg.c:42
uint32_t entry
Definition: isohybrid.c:63
unsigned char xmlChar
Definition: xmlstring.h:28
GLenum GLsizei len
Definition: glext.h:6722
XMLPUBFUN int XMLCALL xmlStrncmp(const xmlChar *str1, const xmlChar *str2, int len)
Definition: xmlstring.c:206
#define MIN_DICT_SIZE
Definition: dict.c:65
static const xmlChar * xmlDictAddString(xmlDictPtr dict, const xmlChar *name, unsigned int namelen)
Definition: dict.c:241
unsigned int len
Definition: dict.c:97
#define MAX_HASH_LEN
Definition: dict.c:64
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
Definition: name.c:36
const xmlChar * name
Definition: dict.c:96
#define xmlDictComputeKey(dict, name, len)
Definition: dict.c:70
unsigned long okey
Definition: dict.c:99
Definition: path.c:42

Referenced by xmlAddAttributeDecl(), xmlAddDefAttrs(), xmlAddID(), xmlCopyDocElementContent(), xmlDetectSAX2(), xmlDictQLookup(), xmlHashAddEntry3(), xmlHashUpdateEntry3(), xmlNewDocElementContent(), xmlParseBalancedChunkMemoryInternal(), xmlParseCtxtExternalEntity(), xmlParseInNodeContext(), xmlParseName(), xmlParseNameComplex(), xmlParseNCName(), xmlParseNCNameComplex(), xmlParseQName(), xmlParseReference(), xmlParseStartTag2(), xmlSAX2TextNode(), xsltAddTemplate(), xsltApplyAttributeSet(), xsltApplyStylesheetInternal(), xsltAttribute(), xsltAttributeComp(), xsltAttrListTemplateProcess(), xsltAttrTemplateProcess(), xsltElement(), xsltElementComp(), xsltEvalStaticAttrValueTemplate(), xsltGetCNsProp(), xsltGetQNameProperty(), xsltGetQNameURI2(), xsltNumberComp(), xsltParseStylesheetAttributeSet(), xsltParseStylesheetTemplate(), xsltParseTemplateContent(), xsltPreprocessStylesheet(), xsltProcessUserParamInternal(), xsltRegisterGlobalVariable(), xsltShallowCopyAttr(), xsltSortComp(), xsltSplitQName(), xsltStackLookup(), and xsltXPathVariableLookup().

◆ xmlDictOwns()

XMLPUBFUN int XMLCALL xmlDictOwns ( xmlDictPtr  dict,
const xmlChar str 
)

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

check if a string is owned by the disctionary

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

Definition at line 1211 of file dict.c.

1211  {
1213 
1214  if ((dict == NULL) || (str == NULL))
1215  return(-1);
1216  pool = dict->strings;
1217  while (pool != NULL) {
1218  if ((str >= &pool->array[0]) && (str <= pool->free))
1219  return(1);
1220  pool = pool->next;
1221  }
1222  if (dict->subdict)
1223  return(xmlDictOwns(dict->subdict, str));
1224  return(0);
1225 }
#define free
Definition: debug_ros.c:5
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
int xmlDictOwns(xmlDictPtr dict, const xmlChar *str)
Definition: dict.c:1211

Referenced by xmlFreeAttribute(), xmlFreeDocElementContent(), xmlHashAddEntry3(), xmlHashUpdateEntry3(), xmlParseEnumerationType(), xmlParseNotationType(), xmlSAX2Characters(), xmlSAX2ExternalSubset(), xsltAttrListTemplateProcess(), xsltAttrTemplateProcess(), xsltCopyText(), xsltParseTemplateContent(), and xsltPreprocessStylesheet().

◆ xmlDictQLookup()

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

Definition at line 1106 of file dict.c.

1106  {
1107  unsigned long okey, key, nbi = 0;
1110  const xmlChar *ret;
1111  unsigned int len, plen, l;
1112 
1113  if ((dict == NULL) || (name == NULL))
1114  return(NULL);
1115  if (prefix == NULL)
1116  return(xmlDictLookup(dict, name, -1));
1117 
1118  l = len = strlen((const char *) name);
1119  plen = strlen((const char *) prefix);
1120  len += 1 + plen;
1121 
1122  /*
1123  * Check for duplicate and insertion location.
1124  */
1125  okey = xmlDictComputeQKey(dict, prefix, plen, name, l);
1126  key = okey % dict->size;
1127  if (dict->dict[key].valid == 0) {
1128  insert = NULL;
1129  } else {
1130  for (insert = &(dict->dict[key]); insert->next != NULL;
1131  insert = insert->next) {
1132  if ((insert->okey == okey) && (insert->len == len) &&
1133  (xmlStrQEqual(prefix, name, insert->name)))
1134  return(insert->name);
1135  nbi++;
1136  }
1137  if ((insert->okey == okey) && (insert->len == len) &&
1138  (xmlStrQEqual(prefix, name, insert->name)))
1139  return(insert->name);
1140  }
1141 
1142  if (dict->subdict) {
1143  unsigned long skey;
1144 
1145  /* we cannot always reuse the same okey for the subdict */
1146  if (((dict->size == MIN_DICT_SIZE) &&
1147  (dict->subdict->size != MIN_DICT_SIZE)) ||
1148  ((dict->size != MIN_DICT_SIZE) &&
1149  (dict->subdict->size == MIN_DICT_SIZE)))
1150  skey = xmlDictComputeQKey(dict->subdict, prefix, plen, name, l);
1151  else
1152  skey = okey;
1153 
1154  key = skey % dict->subdict->size;
1155  if (dict->subdict->dict[key].valid != 0) {
1156  xmlDictEntryPtr tmp;
1157  for (tmp = &(dict->subdict->dict[key]); tmp->next != NULL;
1158  tmp = tmp->next) {
1159  if ((tmp->okey == skey) && (tmp->len == len) &&
1160  (xmlStrQEqual(prefix, name, tmp->name)))
1161  return(tmp->name);
1162  nbi++;
1163  }
1164  if ((tmp->okey == skey) && (tmp->len == len) &&
1165  (xmlStrQEqual(prefix, name, tmp->name)))
1166  return(tmp->name);
1167  }
1168  key = okey % dict->size;
1169  }
1170 
1171  ret = xmlDictAddQString(dict, prefix, plen, name, l);
1172  if (ret == NULL)
1173  return(NULL);
1174  if (insert == NULL) {
1175  entry = &(dict->dict[key]);
1176  } else {
1177  entry = xmlMalloc(sizeof(xmlDictEntry));
1178  if (entry == NULL)
1179  return(NULL);
1180  }
1181  entry->name = ret;
1182  entry->len = len;
1183  entry->next = NULL;
1184  entry->valid = 1;
1185  entry->okey = okey;
1186 
1187  if (insert != NULL)
1188  insert->next = entry;
1189 
1190  dict->nbElems++;
1191 
1192  if ((nbi > MAX_HASH_LEN) &&
1193  (dict->size <= ((MAX_DICT_HASH / 2) / MAX_HASH_LEN)))
1194  xmlDictGrow(dict, MAX_HASH_LEN * 2 * dict->size);
1195  /* Note that entry may have been freed at this point by xmlDictGrow */
1196 
1197  return(ret);
1198 }
static int xmlDictGrow(xmlDictPtr dict, size_t size)
Definition: dict.c:660
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define xmlDictComputeQKey(dict, prefix, plen, name, len)
Definition: dict.c:75
#define MAX_DICT_HASH
Definition: dict.c:66
static int insert
Definition: xmllint.c:144
XMLPUBFUN int XMLCALL xmlStrQEqual(const xmlChar *pref, const xmlChar *name, const xmlChar *str)
Definition: xmlstring.c:179
static const xmlChar * xmlDictAddQString(xmlDictPtr dict, const xmlChar *prefix, unsigned int plen, const xmlChar *name, unsigned int namelen)
Definition: dict.c:305
smooth NULL
Definition: ftsmooth.c:416
r l[0]
Definition: byte_order.h:167
const xmlChar * xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
Definition: dict.c:858
int ret
struct _xmlDictEntry * next
Definition: dict.c:95
HKEY key
Definition: reg.c:42
uint32_t entry
Definition: isohybrid.c:63
unsigned char xmlChar
Definition: xmlstring.h:28
GLenum GLsizei len
Definition: glext.h:6722
#define MIN_DICT_SIZE
Definition: dict.c:65
unsigned int len
Definition: dict.c:97
#define MAX_HASH_LEN
Definition: dict.c:64
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
Definition: name.c:36
const xmlChar * name
Definition: dict.c:96
unsigned long okey
Definition: dict.c:99
Definition: path.c:42

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

◆ xmlDictReference()

XMLPUBFUN int XMLCALL 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 638 of file dict.c.

638  {
639  if (!xmlDictInitialized)
640  if (!__xmlInitializeDict())
641  return(-1);
642 
643  if (dict == NULL) return -1;
645  dict->ref_counter++;
647  return(0);
648 }
XMLPUBFUN void XMLCALL xmlRMutexLock(xmlRMutexPtr tok)
Definition: threads.c:343
static int xmlDictInitialized
Definition: dict.c:139
smooth NULL
Definition: ftsmooth.c:416
static xmlRMutexPtr xmlDictMutex
Definition: dict.c:134
int __xmlInitializeDict(void)
Definition: dict.c:175
XMLPUBFUN void XMLCALL xmlRMutexUnlock(xmlRMutexPtr tok)
Definition: threads.c:388

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

◆ xmlDictSetLimit()

XMLPUBFUN size_t XMLCALL 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 1256 of file dict.c.

1256  {
1257  size_t ret;
1258 
1259  if (dict == NULL)
1260  return(0);
1261  ret = dict->limit;
1262  dict->limit = limit;
1263  return(ret);
1264 }
GLint limit
Definition: glext.h:10326
smooth NULL
Definition: ftsmooth.c:416
int ret

Referenced by xmlCtxtUseOptionsInternal(), and xmlInitParserCtxt().

◆ xmlDictSize()

XMLPUBFUN int XMLCALL 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 1237 of file dict.c.

1237  {
1238  if (dict == NULL)
1239  return(-1);
1240  if (dict->subdict)
1241  return(dict->nbElems + dict->subdict->nbElems);
1242  return(dict->nbElems);
1243 }
smooth NULL
Definition: ftsmooth.c:416

◆ xmlInitializeDict()

XMLPUBFUN int XMLCALL xmlInitializeDict ( void  )

xmlInitializeDict:

Do the dictionary mutex initialization. this function is deprecated

Returns 0 if initialization was already done, and 1 if that call led to the initialization

Definition at line 159 of file dict.c.

159  {
160  return(0);
161 }

Referenced by xmlInitParser().

Variable Documentation

◆ xmlDictPtr