Lines Matching refs:dict
70 #define xmlDictComputeKey(dict, name, len) \ argument
71 (((dict)->size == MIN_DICT_SIZE) ? \
72 xmlDictComputeFastKey(name, len, (dict)->seed) : \
73 xmlDictComputeBigKey(name, len, (dict)->seed))
75 #define xmlDictComputeQKey(dict, prefix, plen, name, len) \ argument
77 (xmlDictComputeKey(dict, name, len)) : \
78 (((dict)->size == MIN_DICT_SIZE) ? \
79 xmlDictComputeFastQKey(prefix, plen, name, len, (dict)->seed) : \
80 xmlDictComputeBigQKey(prefix, plen, name, len, (dict)->seed)))
83 #define xmlDictComputeKey(dict, name, len) \ argument
84 xmlDictComputeFastKey(name, len, (dict)->seed)
85 #define xmlDictComputeQKey(dict, prefix, plen, name, len) \ argument
86 xmlDictComputeFastQKey(prefix, plen, name, len, (dict)->seed)
118 struct _xmlDictEntry *dict; member
241 xmlDictAddString(xmlDictPtr dict, const xmlChar *name, unsigned int namelen) { in xmlDictAddString() argument
250 pool = dict->strings; in xmlDictAddString()
262 if ((dict->limit > 0) && (limit > dict->limit)) { in xmlDictAddString()
277 pool->next = dict->strings; in xmlDictAddString()
278 dict->strings = pool; in xmlDictAddString()
305 xmlDictAddQString(xmlDictPtr dict, const xmlChar *prefix, unsigned int plen, in xmlDictAddQString() argument
313 if (prefix == NULL) return(xmlDictAddString(dict, name, namelen)); in xmlDictAddQString()
318 pool = dict->strings; in xmlDictAddQString()
330 if ((dict->limit > 0) && (limit > dict->limit)) { in xmlDictAddQString()
345 pool->next = dict->strings; in xmlDictAddQString()
346 dict->strings = pool; in xmlDictAddQString()
537 xmlDictPtr dict; in xmlDictCreate() local
547 dict = xmlMalloc(sizeof(xmlDict)); in xmlDictCreate()
548 if (dict) { in xmlDictCreate()
549 dict->ref_counter = 1; in xmlDictCreate()
550 dict->limit = 0; in xmlDictCreate()
552 dict->size = MIN_DICT_SIZE; in xmlDictCreate()
553 dict->nbElems = 0; in xmlDictCreate()
554 dict->dict = xmlMalloc(MIN_DICT_SIZE * sizeof(xmlDictEntry)); in xmlDictCreate()
555 dict->strings = NULL; in xmlDictCreate()
556 dict->subdict = NULL; in xmlDictCreate()
557 if (dict->dict) { in xmlDictCreate()
558 memset(dict->dict, 0, MIN_DICT_SIZE * sizeof(xmlDictEntry)); in xmlDictCreate()
560 dict->seed = __xmlRandom(); in xmlDictCreate()
562 dict->seed = 0; in xmlDictCreate()
564 return(dict); in xmlDictCreate()
566 xmlFree(dict); in xmlDictCreate()
584 xmlDictPtr dict = xmlDictCreate(); in xmlDictCreateSub() local
586 if ((dict != NULL) && (sub != NULL)) { in xmlDictCreateSub()
590 dict->seed = sub->seed; in xmlDictCreateSub()
591 dict->subdict = sub; in xmlDictCreateSub()
592 xmlDictReference(dict->subdict); in xmlDictCreateSub()
594 return(dict); in xmlDictCreateSub()
606 xmlDictReference(xmlDictPtr dict) { in xmlDictReference() argument
611 if (dict == NULL) return -1; in xmlDictReference()
613 dict->ref_counter++; in xmlDictReference()
628 xmlDictGrow(xmlDictPtr dict, size_t size) { in xmlDictGrow() argument
639 if (dict == NULL) in xmlDictGrow()
650 oldsize = dict->size; in xmlDictGrow()
651 olddict = dict->dict; in xmlDictGrow()
657 dict->dict = xmlMalloc(size * sizeof(xmlDictEntry)); in xmlDictGrow()
658 if (dict->dict == NULL) { in xmlDictGrow()
659 dict->dict = olddict; in xmlDictGrow()
662 memset(dict->dict, 0, size * sizeof(xmlDictEntry)); in xmlDictGrow()
663 dict->size = size; in xmlDictGrow()
678 okey = xmlDictComputeKey(dict, olddict[i].name, olddict[i].len); in xmlDictGrow()
679 key = okey % dict->size; in xmlDictGrow()
681 if (dict->dict[key].valid == 0) { in xmlDictGrow()
682 memcpy(&(dict->dict[key]), &(olddict[i]), sizeof(xmlDictEntry)); in xmlDictGrow()
683 dict->dict[key].next = NULL; in xmlDictGrow()
684 dict->dict[key].okey = okey; in xmlDictGrow()
693 entry->next = dict->dict[key].next; in xmlDictGrow()
695 dict->dict[key].next = entry; in xmlDictGrow()
721 okey = xmlDictComputeKey(dict, iter->name, iter->len); in xmlDictGrow()
722 key = okey % dict->size; in xmlDictGrow()
723 if (dict->dict[key].valid == 0) { in xmlDictGrow()
724 memcpy(&(dict->dict[key]), iter, sizeof(xmlDictEntry)); in xmlDictGrow()
725 dict->dict[key].next = NULL; in xmlDictGrow()
726 dict->dict[key].valid = 1; in xmlDictGrow()
727 dict->dict[key].okey = okey; in xmlDictGrow()
730 iter->next = dict->dict[key].next; in xmlDictGrow()
732 dict->dict[key].next = iter; in xmlDictGrow()
761 xmlDictFree(xmlDictPtr dict) { in xmlDictFree() argument
768 if (dict == NULL) in xmlDictFree()
777 dict->ref_counter--; in xmlDictFree()
778 if (dict->ref_counter > 0) { in xmlDictFree()
785 if (dict->subdict != NULL) { in xmlDictFree()
786 xmlDictFree(dict->subdict); in xmlDictFree()
789 if (dict->dict) { in xmlDictFree()
790 for(i = 0; ((i < dict->size) && (dict->nbElems > 0)); i++) { in xmlDictFree()
791 iter = &(dict->dict[i]); in xmlDictFree()
799 dict->nbElems--; in xmlDictFree()
804 xmlFree(dict->dict); in xmlDictFree()
806 pool = dict->strings; in xmlDictFree()
812 xmlFree(dict); in xmlDictFree()
826 xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len) { in xmlDictLookup() argument
833 if ((dict == NULL) || (name == NULL)) in xmlDictLookup()
841 if (((dict->limit > 0) && (l >= dict->limit)) || in xmlDictLookup()
848 okey = xmlDictComputeKey(dict, name, l); in xmlDictLookup()
849 key = okey % dict->size; in xmlDictLookup()
850 if (dict->dict[key].valid == 0) { in xmlDictLookup()
853 for (insert = &(dict->dict[key]); insert->next != NULL; in xmlDictLookup()
879 if (dict->subdict) { in xmlDictLookup()
883 if (((dict->size == MIN_DICT_SIZE) && in xmlDictLookup()
884 (dict->subdict->size != MIN_DICT_SIZE)) || in xmlDictLookup()
885 ((dict->size != MIN_DICT_SIZE) && in xmlDictLookup()
886 (dict->subdict->size == MIN_DICT_SIZE))) in xmlDictLookup()
887 skey = xmlDictComputeKey(dict->subdict, name, l); in xmlDictLookup()
891 key = skey % dict->subdict->size; in xmlDictLookup()
892 if (dict->subdict->dict[key].valid != 0) { in xmlDictLookup()
895 for (tmp = &(dict->subdict->dict[key]); tmp->next != NULL; in xmlDictLookup()
920 key = okey % dict->size; in xmlDictLookup()
923 ret = xmlDictAddString(dict, name, l); in xmlDictLookup()
927 entry = &(dict->dict[key]); in xmlDictLookup()
943 dict->nbElems++; in xmlDictLookup()
946 (dict->size <= ((MAX_DICT_HASH / 2) / MAX_HASH_LEN))) { in xmlDictLookup()
947 if (xmlDictGrow(dict, MAX_HASH_LEN * 2 * dict->size) != 0) in xmlDictLookup()
966 xmlDictExists(xmlDictPtr dict, const xmlChar *name, int len) { in xmlDictExists() argument
971 if ((dict == NULL) || (name == NULL)) in xmlDictExists()
978 if (((dict->limit > 0) && (l >= dict->limit)) || in xmlDictExists()
985 okey = xmlDictComputeKey(dict, name, l); in xmlDictExists()
986 key = okey % dict->size; in xmlDictExists()
987 if (dict->dict[key].valid == 0) { in xmlDictExists()
990 for (insert = &(dict->dict[key]); insert->next != NULL; in xmlDictExists()
1016 if (dict->subdict) { in xmlDictExists()
1020 if (((dict->size == MIN_DICT_SIZE) && in xmlDictExists()
1021 (dict->subdict->size != MIN_DICT_SIZE)) || in xmlDictExists()
1022 ((dict->size != MIN_DICT_SIZE) && in xmlDictExists()
1023 (dict->subdict->size == MIN_DICT_SIZE))) in xmlDictExists()
1024 skey = xmlDictComputeKey(dict->subdict, name, l); in xmlDictExists()
1028 key = skey % dict->subdict->size; in xmlDictExists()
1029 if (dict->subdict->dict[key].valid != 0) { in xmlDictExists()
1032 for (tmp = &(dict->subdict->dict[key]); tmp->next != NULL; in xmlDictExists()
1074 xmlDictQLookup(xmlDictPtr dict, const xmlChar *prefix, const xmlChar *name) { in xmlDictQLookup() argument
1081 if ((dict == NULL) || (name == NULL)) in xmlDictQLookup()
1084 return(xmlDictLookup(dict, name, -1)); in xmlDictQLookup()
1093 okey = xmlDictComputeQKey(dict, prefix, plen, name, l); in xmlDictQLookup()
1094 key = okey % dict->size; in xmlDictQLookup()
1095 if (dict->dict[key].valid == 0) { in xmlDictQLookup()
1098 for (insert = &(dict->dict[key]); insert->next != NULL; in xmlDictQLookup()
1110 if (dict->subdict) { in xmlDictQLookup()
1114 if (((dict->size == MIN_DICT_SIZE) && in xmlDictQLookup()
1115 (dict->subdict->size != MIN_DICT_SIZE)) || in xmlDictQLookup()
1116 ((dict->size != MIN_DICT_SIZE) && in xmlDictQLookup()
1117 (dict->subdict->size == MIN_DICT_SIZE))) in xmlDictQLookup()
1118 skey = xmlDictComputeQKey(dict->subdict, prefix, plen, name, l); in xmlDictQLookup()
1122 key = skey % dict->subdict->size; in xmlDictQLookup()
1123 if (dict->subdict->dict[key].valid != 0) { in xmlDictQLookup()
1125 for (tmp = &(dict->subdict->dict[key]); tmp->next != NULL; in xmlDictQLookup()
1136 key = okey % dict->size; in xmlDictQLookup()
1139 ret = xmlDictAddQString(dict, prefix, plen, name, l); in xmlDictQLookup()
1143 entry = &(dict->dict[key]); in xmlDictQLookup()
1158 dict->nbElems++; in xmlDictQLookup()
1161 (dict->size <= ((MAX_DICT_HASH / 2) / MAX_HASH_LEN))) in xmlDictQLookup()
1162 xmlDictGrow(dict, MAX_HASH_LEN * 2 * dict->size); in xmlDictQLookup()
1179 xmlDictOwns(xmlDictPtr dict, const xmlChar *str) { in xmlDictOwns() argument
1182 if ((dict == NULL) || (str == NULL)) in xmlDictOwns()
1184 pool = dict->strings; in xmlDictOwns()
1190 if (dict->subdict) in xmlDictOwns()
1191 return(xmlDictOwns(dict->subdict, str)); in xmlDictOwns()
1205 xmlDictSize(xmlDictPtr dict) { in xmlDictSize() argument
1206 if (dict == NULL) in xmlDictSize()
1208 if (dict->subdict) in xmlDictSize()
1209 return(dict->nbElems + dict->subdict->nbElems); in xmlDictSize()
1210 return(dict->nbElems); in xmlDictSize()
1224 xmlDictSetLimit(xmlDictPtr dict, size_t limit) { in xmlDictSetLimit() argument
1227 if (dict == NULL) in xmlDictSetLimit()
1229 ret = dict->limit; in xmlDictSetLimit()
1230 dict->limit = limit; in xmlDictSetLimit()
1244 xmlDictGetUsage(xmlDictPtr dict) { in xmlDictGetUsage() argument
1248 if (dict == NULL) in xmlDictGetUsage()
1250 pool = dict->strings; in xmlDictGetUsage()