--- a/libidav/resource.c Thu May 23 23:19:06 2024 +0200 +++ b/libidav/resource.c Thu May 23 23:23:36 2024 +0200 @@ -127,7 +127,6 @@ if(!properties) return; CxIterator i = cxMapIteratorValues(properties); - DavProperty *property; cx_foreach(DavProperty*, property, i) { // TODO: free everything dav_session_free(sn, property); @@ -730,7 +729,7 @@ DavPropName* dav_get_property_names(DavResource *res, size_t *count) { DavResourceData *data = res->data; - *count = data->properties->size; + *count = cxMapSize(data->properties); DavPropName *names = dav_session_calloc( res->session, *count, @@ -738,15 +737,10 @@ CxIterator i = cxMapIteratorValues(data->properties); - DavProperty *value; - int j = 0; cx_foreach(DavProperty*, value, i) { - DavPropName *name = &names[j]; - + DavPropName *name = &names[i.index]; name->ns = value->ns->name; name->name = value->name; - - j++; } qsort(names, *count, sizeof(DavPropName), compare_propname); @@ -998,7 +992,7 @@ if(data->crypto_remove) { CxIterator i = cxListIterator(data->crypto_remove); cx_foreach(DavProperty *, property, i) { - if(crypto_props->size == 0) { + if(cxMapSize(crypto_props) == 0) { break; // map already empty, can't remove any more } @@ -1509,14 +1503,13 @@ // create an xml document containing all properties CxMap *nsmap = cxHashMapCreate(cxDefaultAllocator, CX_STORE_POINTERS, 8); - nsmap->simple_destructor = free; + cxDefineDestructor(nsmap, free); cxMapPut(nsmap, cx_hash_key_str("DAV:"), strdup("D")); cxBufferPutString(content, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); cxBufferPutString(content, "<D:prop xmlns:D=\"DAV:\">\n"); CxIterator i = cxMapIteratorValues(properties); - DavProperty *prop; cx_foreach(DavProperty*, prop, i) { DavXmlNode pnode; pnode.type = DAV_XML_ELEMENT; @@ -1600,15 +1593,15 @@ dav_session_strdup(sn, (const char*)n->ns->prefix) : NULL; property->value = n->children ? dav_convert_xml(sn, n->children) : NULL; - cxmutstr key = dav_property_key(property->ns->name, property->name); - cxMapPut(map, cx_hash_key(key.ptr, key.length), property); - free(key.ptr); + cxmutstr propkey = dav_property_key(property->ns->name, property->name); + cxMapPut(map, cx_hash_key_cxstr(propkey), property); + cx_strfree(&propkey); } n = n->next; } xmlFreeDoc(doc); - if(map->size == 0) { + if(cxMapSize(map) == 0) { cxMapDestroy(map); return NULL; }