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

Function xmlHashCopySafe

ThirdParty/libxml2/vtklibxml2/hash.c:1148–1187  ·  view source on GitHub ↗

* xmlHashCopySafe: * @hash: hash table * @copyFunc: copier function for items in the hash * @deallocFunc: deallocation function in case of errors * * Copy the hash table using @copyFunc to copy payloads. * * Available since 2.13.0. * * Returns the new table or NULL if a memory allocation failed. */

Source from the content-addressed store, hash-verified

1146 * Returns the new table or NULL if a memory allocation failed.
1147 */
1148xmlHashTablePtr
1149xmlHashCopySafe(xmlHashTablePtr hash, xmlHashCopier copyFunc,
1150 xmlHashDeallocator deallocFunc) {
1151 const xmlHashEntry *entry, *end;
1152 xmlHashTablePtr ret;
1153
1154 if ((hash == NULL) || (copyFunc == NULL))
1155 return(NULL);
1156
1157 ret = xmlHashCreate(hash->size);
1158 if (ret == NULL)
1159 return(NULL);
1160
1161 if (hash->size == 0)
1162 return(ret);
1163
1164 end = &hash->table[hash->size];
1165
1166 for (entry = hash->table; entry < end; entry++) {
1167 if (entry->hashValue != 0) {
1168 void *copy;
1169
1170 copy = copyFunc(entry->payload, entry->key);
1171 if (copy == NULL)
1172 goto error;
1173 if (xmlHashAdd3(ret, entry->key, entry->key2, entry->key3,
1174 copy) <= 0) {
1175 if (deallocFunc != NULL)
1176 deallocFunc(copy, entry->key);
1177 goto error;
1178 }
1179 }
1180 }
1181
1182 return(ret);
1183
1184error:
1185 xmlHashFree(ret, deallocFunc);
1186 return(NULL);
1187}
1188
1189/*
1190 * xmlHashCopy:

Callers 5

xmlCopyElementTableFunction · 0.85
xmlCopyAttributeTableFunction · 0.85
xmlCopyNotationTableFunction · 0.85
xmlCopyEntitiesTableFunction · 0.85
xmlHashCopyFunction · 0.85

Calls 3

xmlHashCreateFunction · 0.85
xmlHashAdd3Function · 0.85
xmlHashFreeFunction · 0.85

Tested by

no test coverage detected