ReactOS  0.4.15-dev-425-gc40b086
dict.h File Reference
#include <stddef.h>
#include <libxml/xmlversion.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

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)
 

Typedef Documentation

◆ xmlDict

Definition at line 24 of file dict.h.

◆ xmlDictPtr

typedef xmlDict* xmlDictPtr

Definition at line 25 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 222 of file dict.c.

222  {
223  if (!xmlDictInitialized)
224  return;
225 
227 
228  xmlDictInitialized = 0;
229 }
static int xmlDictInitialized
Definition: dict.c:140
static xmlRMutexPtr xmlDictMutex
Definition: dict.c:135
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 575 of file dict.c.

575  {
576  xmlDictPtr dict;
577 
578  if (!xmlDictInitialized)
579  if (!__xmlInitializeDict())
580  return(NULL);
581 
582 #ifdef DICT_DEBUG_PATTERNS
583  fprintf(stderr, "C");
584 #endif
585 
586  dict = xmlMalloc(sizeof(xmlDict));
587  if (dict) {
588  dict->ref_counter = 1;
589  dict->limit = 0;
590 
591  dict->size = MIN_DICT_SIZE;
592  dict->nbElems = 0;
593  dict->dict = xmlMalloc(MIN_DICT_SIZE * sizeof(xmlDictEntry));
594  dict->strings = NULL;
595  dict->subdict = NULL;
596  if (dict->dict) {
597  memset(dict->dict, 0, MIN_DICT_SIZE * sizeof(xmlDictEntry));
598 #ifdef DICT_RANDOMIZATION
599  dict->seed = __xmlRandom();
600 #else
601  dict->seed = 0;
602 #endif
603  return(dict);
604  }
605  xmlFree(dict);
606  }
607  return(NULL);
608 }
static int xmlDictInitialized
Definition: dict.c:140
int ref_counter
Definition: dict.c:117
struct _xmlDictEntry * dict
Definition: dict.c:119
int __xmlRandom(void)
Definition: dict.c:198
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
struct _xmlDict * subdict
Definition: dict.c:124
smooth NULL
Definition: ftsmooth.c:416
Definition: dict.c:116
int __xmlInitializeDict(void)
Definition: dict.c:176
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
#define MIN_DICT_SIZE
Definition: dict.c:66
size_t limit
Definition: dict.c:128
int seed
Definition: dict.c:126
unsigned int nbElems
Definition: dict.c:121
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
FILE * stderr
#define memset(x, y, z)
Definition: compat.h:39
size_t size
Definition: dict.c:120
xmlDictStringsPtr strings
Definition: dict.c:122

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

◆ 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 622 of file dict.c.

622  {
623  xmlDictPtr dict = xmlDictCreate();
624 
625  if ((dict != NULL) && (sub != NULL)) {
626 #ifdef DICT_DEBUG_PATTERNS
627  fprintf(stderr, "R");
628 #endif
629  dict->seed = sub->seed;
630  dict->subdict = sub;
631  xmlDictReference(dict->subdict);
632  }
633  return(dict);
634 }
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
xmlDictPtr xmlDictCreate(void)
Definition: dict.c:575
struct _xmlDict * subdict
Definition: dict.c:124
smooth NULL
Definition: ftsmooth.c:416
Definition: dict.c:116
int seed
Definition: dict.c:126
FILE * stderr
int xmlDictReference(xmlDictPtr dict)
Definition: dict.c:645

Referenced by xsltNewTransformContext().

◆ xmlDictExists()

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

Definition at line 1005 of file dict.c.

1005  {
1006  unsigned long key, okey, nbi = 0;
1008  unsigned int l;
1009 
1010  if ((dict == NULL) || (name == NULL))
1011  return(NULL);
1012 
1013  if (len < 0)
1014  l = strlen((const char *) name);
1015  else
1016  l = len;
1017  if (((dict->limit > 0) && (l >= dict->limit)) ||
1018  (l > INT_MAX / 2))
1019  return(NULL);
1020 
1021  /*
1022  * Check for duplicate and insertion location.
1023  */
1024  okey = xmlDictComputeKey(dict, name, l);
1025  key = okey % dict->size;
1026  if (dict->dict[key].valid == 0) {
1027  insert = NULL;
1028  } else {
1029  for (insert = &(dict->dict[key]); insert->next != NULL;
1030  insert = insert->next) {
1031 #ifdef __GNUC__
1032  if ((insert->okey == okey) && (insert->len == l)) {
1033  if (!memcmp(insert->name, name, l))
1034  return(insert->name);
1035  }
1036 #else
1037  if ((insert->okey == okey) && (insert->len == l) &&
1038  (!xmlStrncmp(insert->name, name, l)))
1039  return(insert->name);
1040 #endif
1041  nbi++;
1042  }
1043 #ifdef __GNUC__
1044  if ((insert->okey == okey) && (insert->len == l)) {
1045  if (!memcmp(insert->name, name, l))
1046  return(insert->name);
1047  }
1048 #else
1049  if ((insert->okey == okey) && (insert->len == l) &&
1050  (!xmlStrncmp(insert->name, name, l)))
1051  return(insert->name);
1052 #endif
1053  }
1054 
1055  if (dict->subdict) {
1056  unsigned long skey;
1057 
1058  /* we cannot always reuse the same okey for the subdict */
1059  if (((dict->size == MIN_DICT_SIZE) &&
1060  (dict->subdict->size != MIN_DICT_SIZE)) ||
1061  ((dict->size != MIN_DICT_SIZE) &&
1062  (dict->subdict->size == MIN_DICT_SIZE)))
1063  skey = xmlDictComputeKey(dict->subdict, name, l);
1064  else
1065  skey = okey;
1066 
1067  key = skey % dict->subdict->size;
1068  if (dict->subdict->dict[key].valid != 0) {
1069  xmlDictEntryPtr tmp;
1070 
1071  for (tmp = &(dict->subdict->dict[key]); tmp->next != NULL;
1072  tmp = tmp->next) {
1073 #ifdef __GNUC__
1074  if ((tmp->okey == skey) && (tmp->len == l)) {
1075  if (!memcmp(tmp->name, name, l))
1076  return(tmp->name);
1077  }
1078 #else
1079  if ((tmp->okey == skey) && (tmp->len == l) &&
1080  (!xmlStrncmp(tmp->name, name, l)))
1081  return(tmp->name);
1082 #endif
1083  nbi++;
1084  }
1085 #ifdef __GNUC__
1086  if ((tmp->okey == skey) && (tmp->len == l)) {
1087  if (!memcmp(tmp->name, name, l))
1088  return(tmp->name);
1089  }
1090 #else
1091  if ((tmp->okey == skey) && (tmp->len == l) &&
1092  (!xmlStrncmp(tmp->name, name, l)))
1093  return(tmp->name);
1094 #endif
1095  }
1096  }
1097 
1098  /* not found */
1099  return(NULL);
1100 }
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
struct _xmlDictEntry * dict
Definition: dict.c:119
struct _xmlDict * subdict
Definition: dict.c:124
smooth NULL
Definition: ftsmooth.c:416
r l[0]
Definition: byte_order.h:167
struct _xmlDictEntry * next
Definition: dict.c:96
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:66
size_t limit
Definition: dict.c:128
unsigned int len
Definition: dict.c:98
Definition: name.c:38
const xmlChar * name
Definition: dict.c:97
#define xmlDictComputeKey(dict, name, len)
Definition: dict.c:71
size_t size
Definition: dict.c:120
unsigned long okey
Definition: dict.c:100
Definition: path.c:41

◆ 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 800 of file dict.c.

800  {
801  size_t i;
802  xmlDictEntryPtr iter;
804  int inside_dict = 0;
805  xmlDictStringsPtr pool, nextp;
806 
807  if (dict == NULL)
808  return;
809 
810  if (!xmlDictInitialized)
811  if (!__xmlInitializeDict())
812  return;
813 
814  /* decrement the counter, it may be shared by a parser and docs */
816  dict->ref_counter--;
817  if (dict->ref_counter > 0) {
819  return;
820  }
821 
823 
824  if (dict->subdict != NULL) {
825  xmlDictFree(dict->subdict);
826  }
827 
828  if (dict->dict) {
829  for(i = 0; ((i < dict->size) && (dict->nbElems > 0)); i++) {
830  iter = &(dict->dict[i]);
831  if (iter->valid == 0)
832  continue;
833  inside_dict = 1;
834  while (iter) {
835  next = iter->next;
836  if (!inside_dict)
837  xmlFree(iter);
838  dict->nbElems--;
839  inside_dict = 0;
840  iter = next;
841  }
842  }
843  xmlFree(dict->dict);
844  }
845  pool = dict->strings;
846  while (pool != NULL) {
847  nextp = pool->next;
848  xmlFree(pool);
849  pool = nextp;
850  }
851  xmlFree(dict);
852 }
int valid
Definition: dict.c:99
XMLPUBFUN void XMLCALL xmlRMutexLock(xmlRMutexPtr tok)
Definition: threads.c:343
static int xmlDictInitialized
Definition: dict.c:140
int ref_counter
Definition: dict.c:117
struct _xmlDictEntry * dict
Definition: dict.c:119
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:800
struct _xmlDict * subdict
Definition: dict.c:124
smooth NULL
Definition: ftsmooth.c:416
static xmlRMutexPtr xmlDictMutex
Definition: dict.c:135
int __xmlInitializeDict(void)
Definition: dict.c:176
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
XMLPUBFUN void XMLCALL xmlRMutexUnlock(xmlRMutexPtr tok)
Definition: threads.c:388
struct _xmlDictEntry * next
Definition: dict.c:96
static unsigned __int64 next
Definition: rand_nt.c:6
unsigned int nbElems
Definition: dict.c:121
size_t size
Definition: dict.c:120
xmlDictStringsPtr strings
Definition: dict.c:122

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

◆ 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 1283 of file dict.c.

1283  {
1285  size_t limit = 0;
1286 
1287  if (dict == NULL)
1288  return(0);
1289  pool = dict->strings;
1290  while (pool != NULL) {
1291  limit += pool->size;
1292  pool = pool->next;
1293  }
1294  return(limit);
1295 }
GLint limit
Definition: glext.h:10326
smooth NULL
Definition: ftsmooth.c:416
xmlDictStringsPtr strings
Definition: dict.c:122

◆ xmlDictLookup()

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

Definition at line 865 of file dict.c.

865  {
866  unsigned long key, okey, nbi = 0;
869  const xmlChar *ret;
870  unsigned int l;
871 
872  if ((dict == NULL) || (name == NULL))
873  return(NULL);
874 
875  if (len < 0)
876  l = strlen((const char *) name);
877  else
878  l = len;
879 
880  if (((dict->limit > 0) && (l >= dict->limit)) ||
881  (l > INT_MAX / 2))
882  return(NULL);
883 
884  /*
885  * Check for duplicate and insertion location.
886  */
887  okey = xmlDictComputeKey(dict, name, l);
888  key = okey % dict->size;
889  if (dict->dict[key].valid == 0) {
890  insert = NULL;
891  } else {
892  for (insert = &(dict->dict[key]); insert->next != NULL;
893  insert = insert->next) {
894 #ifdef __GNUC__
895  if ((insert->okey == okey) && (insert->len == l)) {
896  if (!memcmp(insert->name, name, l))
897  return(insert->name);
898  }
899 #else
900  if ((insert->okey == okey) && (insert->len == l) &&
901  (!xmlStrncmp(insert->name, name, l)))
902  return(insert->name);
903 #endif
904  nbi++;
905  }
906 #ifdef __GNUC__
907  if ((insert->okey == okey) && (insert->len == l)) {
908  if (!memcmp(insert->name, name, l))
909  return(insert->name);
910  }
911 #else
912  if ((insert->okey == okey) && (insert->len == l) &&
913  (!xmlStrncmp(insert->name, name, l)))
914  return(insert->name);
915 #endif
916  }
917 
918  if (dict->subdict) {
919  unsigned long skey;
920 
921  /* we cannot always reuse the same okey for the subdict */
922  if (((dict->size == MIN_DICT_SIZE) &&
923  (dict->subdict->size != MIN_DICT_SIZE)) ||
924  ((dict->size != MIN_DICT_SIZE) &&
925  (dict->subdict->size == MIN_DICT_SIZE)))
926  skey = xmlDictComputeKey(dict->subdict, name, l);
927  else
928  skey = okey;
929 
930  key = skey % dict->subdict->size;
931  if (dict->subdict->dict[key].valid != 0) {
932  xmlDictEntryPtr tmp;
933 
934  for (tmp = &(dict->subdict->dict[key]); tmp->next != NULL;
935  tmp = tmp->next) {
936 #ifdef __GNUC__
937  if ((tmp->okey == skey) && (tmp->len == l)) {
938  if (!memcmp(tmp->name, name, l))
939  return(tmp->name);
940  }
941 #else
942  if ((tmp->okey == skey) && (tmp->len == l) &&
943  (!xmlStrncmp(tmp->name, name, l)))
944  return(tmp->name);
945 #endif
946  nbi++;
947  }
948 #ifdef __GNUC__
949  if ((tmp->okey == skey) && (tmp->len == l)) {
950  if (!memcmp(tmp->name, name, l))
951  return(tmp->name);
952  }
953 #else
954  if ((tmp->okey == skey) && (tmp->len == l) &&
955  (!xmlStrncmp(tmp->name, name, l)))
956  return(tmp->name);
957 #endif
958  }
959  key = okey % dict->size;
960  }
961 
962  ret = xmlDictAddString(dict, name, l);
963  if (ret == NULL)
964  return(NULL);
965  if (insert == NULL) {
966  entry = &(dict->dict[key]);
967  } else {
968  entry = xmlMalloc(sizeof(xmlDictEntry));
969  if (entry == NULL)
970  return(NULL);
971  }
972  entry->name = ret;
973  entry->len = l;
974  entry->next = NULL;
975  entry->valid = 1;
976  entry->okey = okey;
977 
978 
979  if (insert != NULL)
980  insert->next = entry;
981 
982  dict->nbElems++;
983 
984  if ((nbi > MAX_HASH_LEN) &&
985  (dict->size <= ((MAX_DICT_HASH / 2) / MAX_HASH_LEN))) {
986  if (xmlDictGrow(dict, MAX_HASH_LEN * 2 * dict->size) != 0)
987  return(NULL);
988  }
989  /* Note that entry may have been freed at this point by xmlDictGrow */
990 
991  return(ret);
992 }
static int xmlDictGrow(xmlDictPtr dict, size_t size)
Definition: dict.c:667
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:67
static int insert
Definition: xmllint.c:144
struct _xmlDictEntry * dict
Definition: dict.c:119
struct _xmlDict * subdict
Definition: dict.c:124
smooth NULL
Definition: ftsmooth.c:416
r l[0]
Definition: byte_order.h:167
int ret
struct _xmlDictEntry * next
Definition: dict.c:96
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:66
size_t limit
Definition: dict.c:128
static const xmlChar * xmlDictAddString(xmlDictPtr dict, const xmlChar *name, unsigned int namelen)
Definition: dict.c:242
unsigned int len
Definition: dict.c:98
unsigned int nbElems
Definition: dict.c:121
#define MAX_HASH_LEN
Definition: dict.c:65
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
Definition: name.c:38
const xmlChar * name
Definition: dict.c:97
#define xmlDictComputeKey(dict, name, len)
Definition: dict.c:71
size_t size
Definition: dict.c:120
unsigned long okey
Definition: dict.c:100
Definition: path.c:41

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 dictionary

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

Definition at line 1218 of file dict.c.

1218  {
1220 
1221  if ((dict == NULL) || (str == NULL))
1222  return(-1);
1223  pool = dict->strings;
1224  while (pool != NULL) {
1225  if ((str >= &pool->array[0]) && (str <= pool->free))
1226  return(1);
1227  pool = pool->next;
1228  }
1229  if (dict->subdict)
1230  return(xmlDictOwns(dict->subdict, str));
1231  return(0);
1232 }
#define free
Definition: debug_ros.c:5
struct _xmlDict * subdict
Definition: dict.c:124
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
int xmlDictOwns(xmlDictPtr dict, const xmlChar *str)
Definition: dict.c:1218
xmlDictStringsPtr strings
Definition: dict.c:122

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 1113 of file dict.c.

1113  {
1114  unsigned long okey, key, nbi = 0;
1117  const xmlChar *ret;
1118  unsigned int len, plen, l;
1119 
1120  if ((dict == NULL) || (name == NULL))
1121  return(NULL);
1122  if (prefix == NULL)
1123  return(xmlDictLookup(dict, name, -1));
1124 
1125  l = len = strlen((const char *) name);
1126  plen = strlen((const char *) prefix);
1127  len += 1 + plen;
1128 
1129  /*
1130  * Check for duplicate and insertion location.
1131  */
1132  okey = xmlDictComputeQKey(dict, prefix, plen, name, l);
1133  key = okey % dict->size;
1134  if (dict->dict[key].valid == 0) {
1135  insert = NULL;
1136  } else {
1137  for (insert = &(dict->dict[key]); insert->next != NULL;
1138  insert = insert->next) {
1139  if ((insert->okey == okey) && (insert->len == len) &&
1140  (xmlStrQEqual(prefix, name, insert->name)))
1141  return(insert->name);
1142  nbi++;
1143  }
1144  if ((insert->okey == okey) && (insert->len == len) &&
1145  (xmlStrQEqual(prefix, name, insert->name)))
1146  return(insert->name);
1147  }
1148 
1149  if (dict->subdict) {
1150  unsigned long skey;
1151 
1152  /* we cannot always reuse the same okey for the subdict */
1153  if (((dict->size == MIN_DICT_SIZE) &&
1154  (dict->subdict->size != MIN_DICT_SIZE)) ||
1155  ((dict->size != MIN_DICT_SIZE) &&
1156  (dict->subdict->size == MIN_DICT_SIZE)))
1157  skey = xmlDictComputeQKey(dict->subdict, prefix, plen, name, l);
1158  else
1159  skey = okey;
1160 
1161  key = skey % dict->subdict->size;
1162  if (dict->subdict->dict[key].valid != 0) {
1163  xmlDictEntryPtr tmp;
1164  for (tmp = &(dict->subdict->dict[key]); tmp->next != NULL;
1165  tmp = tmp->next) {
1166  if ((tmp->okey == skey) && (tmp->len == len) &&
1167  (xmlStrQEqual(prefix, name, tmp->name)))
1168  return(tmp->name);
1169  nbi++;
1170  }
1171  if ((tmp->okey == skey) && (tmp->len == len) &&
1172  (xmlStrQEqual(prefix, name, tmp->name)))
1173  return(tmp->name);
1174  }
1175  key = okey % dict->size;
1176  }
1177 
1178  ret = xmlDictAddQString(dict, prefix, plen, name, l);
1179  if (ret == NULL)
1180  return(NULL);
1181  if (insert == NULL) {
1182  entry = &(dict->dict[key]);
1183  } else {
1184  entry = xmlMalloc(sizeof(xmlDictEntry));
1185  if (entry == NULL)
1186  return(NULL);
1187  }
1188  entry->name = ret;
1189  entry->len = len;
1190  entry->next = NULL;
1191  entry->valid = 1;
1192  entry->okey = okey;
1193 
1194  if (insert != NULL)
1195  insert->next = entry;
1196 
1197  dict->nbElems++;
1198 
1199  if ((nbi > MAX_HASH_LEN) &&
1200  (dict->size <= ((MAX_DICT_HASH / 2) / MAX_HASH_LEN)))
1201  xmlDictGrow(dict, MAX_HASH_LEN * 2 * dict->size);
1202  /* Note that entry may have been freed at this point by xmlDictGrow */
1203 
1204  return(ret);
1205 }
static int xmlDictGrow(xmlDictPtr dict, size_t size)
Definition: dict.c:667
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define xmlDictComputeQKey(dict, prefix, plen, name, len)
Definition: dict.c:76
#define MAX_DICT_HASH
Definition: dict.c:67
static int insert
Definition: xmllint.c:144
XMLPUBFUN int XMLCALL xmlStrQEqual(const xmlChar *pref, const xmlChar *name, const xmlChar *str)
Definition: xmlstring.c:179
struct _xmlDictEntry * dict
Definition: dict.c:119
static const xmlChar * xmlDictAddQString(xmlDictPtr dict, const xmlChar *prefix, unsigned int plen, const xmlChar *name, unsigned int namelen)
Definition: dict.c:306
struct _xmlDict * subdict
Definition: dict.c:124
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:865
int ret
struct _xmlDictEntry * next
Definition: dict.c:96
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:66
unsigned int len
Definition: dict.c:98
unsigned int nbElems
Definition: dict.c:121
#define MAX_HASH_LEN
Definition: dict.c:65
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
Definition: name.c:38
const xmlChar * name
Definition: dict.c:97
size_t size
Definition: dict.c:120
unsigned long okey
Definition: dict.c:100
Definition: path.c:41

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 645 of file dict.c.

645  {
646  if (!xmlDictInitialized)
647  if (!__xmlInitializeDict())
648  return(-1);
649 
650  if (dict == NULL) return -1;
652  dict->ref_counter++;
654  return(0);
655 }
XMLPUBFUN void XMLCALL xmlRMutexLock(xmlRMutexPtr tok)
Definition: threads.c:343
static int xmlDictInitialized
Definition: dict.c:140
int ref_counter
Definition: dict.c:117
smooth NULL
Definition: ftsmooth.c:416
static xmlRMutexPtr xmlDictMutex
Definition: dict.c:135
int __xmlInitializeDict(void)
Definition: dict.c:176
XMLPUBFUN void XMLCALL xmlRMutexUnlock(xmlRMutexPtr tok)
Definition: threads.c:388

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

◆ 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 1263 of file dict.c.

1263  {
1264  size_t ret;
1265 
1266  if (dict == NULL)
1267  return(0);
1268  ret = dict->limit;
1269  dict->limit = limit;
1270  return(ret);
1271 }
GLint limit
Definition: glext.h:10326
smooth NULL
Definition: ftsmooth.c:416
int ret
size_t limit
Definition: dict.c:128

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 1244 of file dict.c.

1244  {
1245  if (dict == NULL)
1246  return(-1);
1247  if (dict->subdict)
1248  return(dict->nbElems + dict->subdict->nbElems);
1249  return(dict->nbElems);
1250 }
struct _xmlDict * subdict
Definition: dict.c:124
smooth NULL
Definition: ftsmooth.c:416
unsigned int nbElems
Definition: dict.c:121

◆ 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 160 of file dict.c.

160  {
161  return(0);
162 }

Referenced by xmlInitParser().