dav/tags.c

changeset 769
24b317ce5ca9
parent 768
eb495f3d4065
child 785
645f7e802873
equal deleted inserted replaced
768:eb495f3d4065 769:24b317ce5ca9
426 // merged taglist 426 // merged taglist
427 CxList *new_tags = cxLinkedListCreateSimple(CX_STORE_POINTERS); 427 CxList *new_tags = cxLinkedListCreateSimple(CX_STORE_POINTERS);
428 new_tags->simple_destructor = (cx_destructor_func)free_dav_tag; 428 new_tags->simple_destructor = (cx_destructor_func)free_dav_tag;
429 429
430 // add all local tags 430 // add all local tags
431 CxIterator iter = cxListIterator(tags1); 431 if(tags1) {
432 cx_foreach(DavTag*, t, iter) { 432 CxIterator iter = cxListIterator(tags1);
433 cxMapPut(tag_map, cx_hash_key_str(t->name), t); 433 cx_foreach(DavTag*, t, iter) {
434 DavTag *newt = calloc(1, sizeof(DavTag)); 434 cxMapPut(tag_map, cx_hash_key_str(t->name), t);
435 newt->color = t->color ? strdup(t->color) : NULL;
436 newt->name = strdup(t->name);
437 cxListAdd(new_tags, newt);
438 }
439 // check if a remote tag is already in the map
440 // and if not add it to the new taglist
441 iter = cxListIterator(tags2);
442 cx_foreach(DavTag*, t, iter) {
443 if(!cxMapGet(tag_map, cx_hash_key_str(t->name))) {
444 DavTag *newt = calloc(1, sizeof(DavTag)); 435 DavTag *newt = calloc(1, sizeof(DavTag));
445 newt->color = t->color ? strdup(t->color) : NULL; 436 newt->color = t->color ? strdup(t->color) : NULL;
446 newt->name = strdup(t->name); 437 newt->name = strdup(t->name);
447 cxListAdd(new_tags, newt); 438 cxListAdd(new_tags, newt);
439 }
440 }
441
442 // check if a remote tag is already in the map
443 // and if not add it to the new taglist
444 if(tags2) {
445 CxIterator iter = cxListIterator(tags2);
446 cx_foreach(DavTag*, t, iter) {
447 if(!cxMapGet(tag_map, cx_hash_key_str(t->name))) {
448 DavTag *newt = calloc(1, sizeof(DavTag));
449 newt->color = t->color ? strdup(t->color) : NULL;
450 newt->name = strdup(t->name);
451 cxListAdd(new_tags, newt);
452 }
448 } 453 }
449 } 454 }
450 455
451 cxMapDestroy(tag_map); 456 cxMapDestroy(tag_map);
452 457

mercurial