ReactOS 0.4.15-dev-8021-g7ce96fd
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

XML_DEPRECATED 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)
 
XML_DEPRECATED 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()

XML_DEPRECATED XMLPUBFUN void XMLCALL xmlDictCleanup ( void  )

xmlDictCleanup:

DEPRECATED: This function will be made private. 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.

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

Definition at line 224 of file dict.c.

224 {
226 return;
227
229
231}
static xmlMutexPtr xmlDictMutex
Definition: dict.c:130
static int xmlDictInitialized
Definition: dict.c:135
XMLPUBFUN void XMLCALL xmlFreeMutex(xmlMutexPtr tok)
Definition: threads.c:197

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

577 {
578 xmlDictPtr dict;
579
581 if (!__xmlInitializeDict())
582 return(NULL);
583
584#ifdef DICT_DEBUG_PATTERNS
585 fprintf(stderr, "C");
586#endif
587
588 dict = xmlMalloc(sizeof(xmlDict));
589 if (dict) {
590 dict->ref_counter = 1;
591 dict->limit = 0;
592
593 dict->size = MIN_DICT_SIZE;
594 dict->nbElems = 0;
595 dict->dict = xmlMalloc(MIN_DICT_SIZE * sizeof(xmlDictEntry));
596 dict->strings = NULL;
597 dict->subdict = NULL;
598 if (dict->dict) {
599 memset(dict->dict, 0, MIN_DICT_SIZE * sizeof(xmlDictEntry));
600#ifdef DICT_RANDOMIZATION
601 dict->seed = __xmlRandom();
602#else
603 dict->seed = 0;
604#endif
605 return(dict);
606 }
607 xmlFree(dict);
608 }
609 return(NULL);
610}
#define NULL
Definition: types.h:112
#define stderr
Definition: stdio.h:100
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:248
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:251
#define MIN_DICT_SIZE
Definition: dict.c:61
int __xmlRandom(void)
Definition: dict.c:195
int __xmlInitializeDict(void)
Definition: dict.c:173
#define memset(x, y, z)
Definition: compat.h:39
Definition: dict.c:111
struct _xmlDictEntry * dict
Definition: dict.c:114
size_t limit
Definition: dict.c:123
xmlDictStringsPtr strings
Definition: dict.c:117
struct _xmlDict * subdict
Definition: dict.c:119
int ref_counter
Definition: dict.c:112
unsigned int nbElems
Definition: dict.c:116
size_t size
Definition: dict.c:115
int seed
Definition: dict.c:121

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

624 {
625 xmlDictPtr dict = xmlDictCreate();
626
627 if ((dict != NULL) && (sub != NULL)) {
628#ifdef DICT_DEBUG_PATTERNS
629 fprintf(stderr, "R");
630#endif
631 dict->seed = sub->seed;
632 dict->subdict = sub;
634 }
635 return(dict);
636}
int xmlDictReference(xmlDictPtr dict)
Definition: dict.c:647
xmlDictPtr xmlDictCreate(void)
Definition: dict.c:577

Referenced by xsltNewTransformContext().

◆ xmlDictExists()

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

Definition at line 1007 of file dict.c.

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

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

802 {
803 size_t i;
804 xmlDictEntryPtr iter;
806 int inside_dict = 0;
807 xmlDictStringsPtr pool, nextp;
808
809 if (dict == NULL)
810 return;
811
813 if (!__xmlInitializeDict())
814 return;
815
816 /* decrement the counter, it may be shared by a parser and docs */
818 dict->ref_counter--;
819 if (dict->ref_counter > 0) {
821 return;
822 }
823
825
826 if (dict->subdict != NULL) {
827 xmlDictFree(dict->subdict);
828 }
829
830 if (dict->dict) {
831 for(i = 0; ((i < dict->size) && (dict->nbElems > 0)); i++) {
832 iter = &(dict->dict[i]);
833 if (iter->valid == 0)
834 continue;
835 inside_dict = 1;
836 while (iter) {
837 next = iter->next;
838 if (!inside_dict)
839 xmlFree(iter);
840 dict->nbElems--;
841 inside_dict = 0;
842 iter = next;
843 }
844 }
845 xmlFree(dict->dict);
846 }
847 pool = dict->strings;
848 while (pool != NULL) {
849 nextp = pool->next;
850 xmlFree(pool);
851 pool = nextp;
852 }
853 xmlFree(dict);
854}
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
static unsigned __int64 next
Definition: rand_nt.c:6
void xmlDictFree(xmlDictPtr dict)
Definition: dict.c:802
int valid
Definition: dict.c:94
XMLPUBFUN void XMLCALL xmlMutexUnlock(xmlMutexPtr tok)
Definition: threads.c:248
XMLPUBFUN void XMLCALL xmlMutexLock(xmlMutexPtr tok)
Definition: threads.c:220

Referenced by xmlDictFree(), xmlFreeParserCtxt(), xmlHashFree(), xmlParseBalancedChunkMemoryInternal(), xmlParseExternalEntityPrivate(), 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 1285 of file dict.c.

1285 {
1287 size_t limit = 0;
1288
1289 if (dict == NULL)
1290 return(0);
1291 pool = dict->strings;
1292 while (pool != NULL) {
1293 limit += pool->size;
1294 pool = pool->next;
1295 }
1296 return(limit);
1297}
GLint limit
Definition: glext.h:10326

◆ xmlDictLookup()

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

Definition at line 867 of file dict.c.

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

Referenced by xmlAddAttributeDecl(), xmlAddDefAttrs(), xmlAddID(), xmlCopyDocElementContent(), xmlDetectSAX2(), xmlDictQLookup(), xmlHashAddEntry3(), xmlHashUpdateEntry3(), xmlNewDocElementContent(), xmlParseBalancedChunkMemoryInternal(), xmlParseExternalEntityPrivate(), 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 1220 of file dict.c.

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

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

◆ xmlDictQLookup()

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

Definition at line 1115 of file dict.c.

1115 {
1116 unsigned long okey, key, nbi = 0;
1119 const xmlChar *ret;
1120 unsigned int len, plen, l;
1121
1122 if ((dict == NULL) || (name == NULL))
1123 return(NULL);
1124 if (prefix == NULL)
1125 return(xmlDictLookup(dict, name, -1));
1126
1127 l = len = strlen((const char *) name);
1128 plen = strlen((const char *) prefix);
1129 len += 1 + plen;
1130
1131 /*
1132 * Check for duplicate and insertion location.
1133 */
1134 okey = xmlDictComputeQKey(dict, prefix, plen, name, l);
1135 key = okey % dict->size;
1136 if (dict->dict[key].valid == 0) {
1137 insert = NULL;
1138 } else {
1139 for (insert = &(dict->dict[key]); insert->next != NULL;
1140 insert = insert->next) {
1141 if ((insert->okey == okey) && (insert->len == len) &&
1142 (xmlStrQEqual(prefix, name, insert->name)))
1143 return(insert->name);
1144 nbi++;
1145 }
1146 if ((insert->okey == okey) && (insert->len == len) &&
1147 (xmlStrQEqual(prefix, name, insert->name)))
1148 return(insert->name);
1149 }
1150
1151 if (dict->subdict) {
1152 unsigned long skey;
1153
1154 /* we cannot always reuse the same okey for the subdict */
1155 if (((dict->size == MIN_DICT_SIZE) &&
1156 (dict->subdict->size != MIN_DICT_SIZE)) ||
1157 ((dict->size != MIN_DICT_SIZE) &&
1158 (dict->subdict->size == MIN_DICT_SIZE)))
1159 skey = xmlDictComputeQKey(dict->subdict, prefix, plen, name, l);
1160 else
1161 skey = okey;
1162
1163 key = skey % dict->subdict->size;
1164 if (dict->subdict->dict[key].valid != 0) {
1165 xmlDictEntryPtr tmp;
1166 for (tmp = &(dict->subdict->dict[key]); tmp->next != NULL;
1167 tmp = tmp->next) {
1168 if ((tmp->okey == skey) && (tmp->len == len) &&
1169 (xmlStrQEqual(prefix, name, tmp->name)))
1170 return(tmp->name);
1171 nbi++;
1172 }
1173 if ((tmp->okey == skey) && (tmp->len == len) &&
1174 (xmlStrQEqual(prefix, name, tmp->name)))
1175 return(tmp->name);
1176 }
1177 key = okey % dict->size;
1178 }
1179
1180 ret = xmlDictAddQString(dict, prefix, plen, name, l);
1181 if (ret == NULL)
1182 return(NULL);
1183 if (insert == NULL) {
1184 entry = &(dict->dict[key]);
1185 } else {
1186 entry = xmlMalloc(sizeof(xmlDictEntry));
1187 if (entry == NULL)
1188 return(NULL);
1189 }
1190 entry->name = ret;
1191 entry->len = len;
1192 entry->next = NULL;
1193 entry->valid = 1;
1194 entry->okey = okey;
1195
1196 if (insert != NULL)
1197 insert->next = entry;
1198
1199 dict->nbElems++;
1200
1201 if ((nbi > MAX_HASH_LEN) &&
1202 (dict->size <= ((MAX_DICT_HASH / 2) / MAX_HASH_LEN)))
1203 xmlDictGrow(dict, MAX_HASH_LEN * 2 * dict->size);
1204 /* Note that entry may have been freed at this point by xmlDictGrow */
1205
1206 return(ret);
1207}
static const xmlChar * xmlDictAddQString(xmlDictPtr dict, const xmlChar *prefix, unsigned int plen, const xmlChar *name, unsigned int namelen)
Definition: dict.c:308
#define xmlDictComputeQKey(dict, prefix, plen, name, len)
Definition: dict.c:71
const xmlChar * xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
Definition: dict.c:867
XMLPUBFUN int XMLCALL xmlStrQEqual(const xmlChar *pref, const xmlChar *name, const xmlChar *str)
Definition: xmlstring.c:186

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

647 {
649 if (!__xmlInitializeDict())
650 return(-1);
651
652 if (dict == NULL) return -1;
654 dict->ref_counter++;
656 return(0);
657}

Referenced by xmlDictCreateSub(), xmlHashCreateDict(), xmlParseBalancedChunkMemoryInternal(), 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 1265 of file dict.c.

1265 {
1266 size_t ret;
1267
1268 if (dict == NULL)
1269 return(0);
1270 ret = dict->limit;
1271 dict->limit = limit;
1272 return(ret);
1273}

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

1246 {
1247 if (dict == NULL)
1248 return(-1);
1249 if (dict->subdict)
1250 return(dict->nbElems + dict->subdict->nbElems);
1251 return(dict->nbElems);
1252}

◆ xmlInitializeDict()

XML_DEPRECATED XMLPUBFUN int XMLCALL xmlInitializeDict ( void  )

xmlInitializeDict:

DEPRECATED: This function will be made private. Call xmlInitParser to initialize the library.

Do the dictionary mutex initialization.

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

Definition at line 157 of file dict.c.

157 {
158 return(0);
159}

Referenced by xmlInitParser().