MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlHashCreate

Function xmlHashCreate

ThirdParty/libxml2/vtklibxml2/hash.c:159–195  ·  view source on GitHub ↗

* xmlHashCreate: * @size: initial size of the hash table * * Create a new hash table. Set size to zero if the number of entries * can't be estimated. * * Returns the newly created object, or NULL if a memory allocation failed. */

Source from the content-addressed store, hash-verified

157 * Returns the newly created object, or NULL if a memory allocation failed.
158 */
159xmlHashTablePtr
160xmlHashCreate(int size) {
161 xmlHashTablePtr hash;
162
163 xmlInitParser();
164
165 hash = xmlMalloc(sizeof(*hash));
166 if (hash == NULL)
167 return(NULL);
168 hash->dict = NULL;
169 hash->size = 0;
170 hash->table = NULL;
171 hash->nbElems = 0;
172 hash->randomSeed = xmlRandom();
173#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
174 hash->randomSeed = 0;
175#endif
176
177 /*
178 * Unless a larger size is passed, the backing table is created
179 * lazily with MIN_HASH_SIZE capacity. In practice, there are many
180 * hash tables which are never filled.
181 */
182 if (size > MIN_HASH_SIZE) {
183 unsigned newSize = MIN_HASH_SIZE * 2;
184
185 while ((newSize < (unsigned) size) && (newSize < MAX_HASH_SIZE))
186 newSize *= 2;
187
188 if (xmlHashGrow(hash, newSize) != 0) {
189 xmlFree(hash);
190 return(NULL);
191 }
192 }
193
194 return(hash);
195}
196
197/**
198 * xmlHashCreateDict:

Callers 15

xmlCreateNewCatalogFunction · 0.85
xmlFetchXMLCatalogFileFunction · 0.85
xmlACatalogAddFunction · 0.85
xmlNewCatalogFunction · 0.85
xmlXPathDistinctSortedFunction · 0.85
xmlXPathRegisterFuncNSFunction · 0.85
xmlXPathRegisterNsFunction · 0.85
xmlParseCRNG_bindPrefixFunction · 0.85
xmlCreateEntitiesTableFunction · 0.85

Calls 3

xmlInitParserFunction · 0.85
xmlRandomFunction · 0.85
xmlHashGrowFunction · 0.85

Tested by 1

saxParseTestFunction · 0.68