src/server/webdav/xattrbackend.c

changeset 490
d218607f5a7e
parent 484
c036a8b242a8
equal deleted inserted replaced
489:921f83a8943f 490:d218607f5a7e
217 217
218 CxHashKey key = webdav_property_key_a( 218 CxHashKey key = webdav_property_key_a(
219 a, 219 a,
220 (const char*)reqprop->namespace->href, 220 (const char*)reqprop->namespace->href,
221 (const char*)reqprop->name); 221 (const char*)reqprop->name);
222 if(!key.data.str) { 222 if(!key.data) {
223 return 1; 223 return 1;
224 } 224 }
225 225
226 WebdavProperty *prop = cxMapGet(pmap, key); 226 WebdavProperty *prop = cxMapGet(pmap, key);
227 if(prop) { 227 if(prop) {
297 if(xattr_data) { 297 if(xattr_data) {
298 pmap = webdav_xattr_parse_data(a, xattr_data, xattr_data_len, path); 298 pmap = webdav_xattr_parse_data(a, xattr_data, xattr_data_len, path);
299 pool_free(sn->pool, xattr_data); 299 pool_free(sn->pool, xattr_data);
300 } else { 300 } else {
301 // empty map 301 // empty map
302 pmap = cxHashMapCreate(a, request->setcount + 8); 302 pmap = cxHashMapCreate(a, CX_STORE_POINTERS, request->setcount + 8);
303 } 303 }
304 if(!pmap) { 304 if(!pmap) {
305 return 1; 305 return 1;
306 } 306 }
307 xprop->properties = pmap; 307 xprop->properties = pmap;
319 319
320 CxHashKey key = webdav_property_key_a( 320 CxHashKey key = webdav_property_key_a(
321 a, 321 a,
322 (const char*)prop->namespace->href, 322 (const char*)prop->namespace->href,
323 (const char*)prop->name); 323 (const char*)prop->name);
324 if(!key.data.str) { 324 if(!key.data) {
325 cxMapDestroy(pmap); 325 cxMapDestroy(pmap);
326 return 1; 326 return 1;
327 } 327 }
328 void *rmprop = cxMapRemove(pmap, key); 328 void *rmprop = cxMapRemoveAndGet(pmap, key);
329 cxFree(a, key.data.str); 329 cxFree(a, (void*)key.data);
330 330
331 // TODO: free rmprop 331 // TODO: free rmprop
332 332
333 if(rmprop) { 333 if(rmprop) {
334 webdav_plist_iterator_remove_current(&i); 334 webdav_plist_iterator_remove_current(&i);
507 int webdav_xattr_put_prop(CxMap *pmap, WebdavProperty *prop) { 507 int webdav_xattr_put_prop(CxMap *pmap, WebdavProperty *prop) {
508 CxHashKey key = webdav_property_key_a( 508 CxHashKey key = webdav_property_key_a(
509 pmap->allocator, 509 pmap->allocator,
510 (const char*)prop->namespace->href, 510 (const char*)prop->namespace->href,
511 (const char*)prop->name); 511 (const char*)prop->name);
512 if(!key.data.str) { 512 if(!key.data) {
513 return 1; 513 return 1;
514 } 514 }
515 int ret = cxMapPut(pmap, key, prop); 515 int ret = cxMapPut(pmap, key, prop);
516 cxFree(pmap->allocator, key.data.str); 516 cxFree(pmap->allocator, (void*)key.data);
517 return ret; 517 return ret;
518 } 518 }
519 519
520 CxMap* webdav_xattr_parse_data(CxAllocator *a, const char *data, size_t len, const char *path) { 520 CxMap* webdav_xattr_parse_data(CxAllocator *a, const char *data, size_t len, const char *path) {
521 CxMap *pmap = cxHashMapCreate(a, 32); 521 CxMap *pmap = cxHashMapCreate(a, CX_STORE_POINTERS, 32);
522 if(!pmap) { 522 if(!pmap) {
523 return NULL; 523 return NULL;
524 } 524 }
525 cxstring dat = cx_strn(data, len); 525 cxstring dat = cx_strn(data, len);
526 526

mercurial