MCPcopy Create free account
hub / github.com/corosync/corosync / remove_deleted_entries

Function remove_deleted_entries

exec/cfg.c:660–708  ·  view source on GitHub ↗

* Remove entries that exist in the global map, but not in the temp_map, this will * cause delete notifications to be sent to any listeners. * * NOTE: This routine depends entirely on the keys returned by the iterators * being in alpha-sorted order. */

Source from the content-addressed store, hash-verified

658 * being in alpha-sorted order.
659 */
660static void remove_deleted_entries(icmap_map_t temp_map, const char *prefix)
661{
662 icmap_iter_t old_iter;
663 icmap_iter_t new_iter;
664 const char *old_key, *new_key;
665 int ret;
666
667 old_iter = icmap_iter_init(prefix);
668 new_iter = icmap_iter_init_r(temp_map, prefix);
669
670 old_key = icmap_iter_next(old_iter, NULL, NULL);
671 new_key = icmap_iter_next(new_iter, NULL, NULL);
672
673 while (old_key || new_key) {
674 ret = nullcheck_strcmp(old_key, new_key);
675 if ((ret < 0 && old_key) || !new_key) {
676 /*
677 * new_key is greater, a line (or more) has been deleted
678 * Continue until old is >= new
679 */
680 do {
681 /* Remove it from icmap & send notifications */
682 icmap_delete(old_key);
683
684 old_key = icmap_iter_next(old_iter, NULL, NULL);
685 ret = nullcheck_strcmp(old_key, new_key);
686 } while (ret < 0 && old_key);
687 }
688 else if ((ret > 0 && new_key) || !old_key) {
689 /*
690 * old_key is greater, a line (or more) has been added
691 * Continue until new is >= old
692 *
693 * we don't need to do anything special with this like tell
694 * icmap. That will happen when we copy the values over
695 */
696 do {
697 new_key = icmap_iter_next(new_iter, NULL, NULL);
698 ret = nullcheck_strcmp(old_key, new_key);
699 } while (ret > 0 && new_key);
700 }
701 if (ret == 0) {
702 new_key = icmap_iter_next(new_iter, NULL, NULL);
703 old_key = icmap_iter_next(old_iter, NULL, NULL);
704 }
705 }
706 icmap_iter_finalize(new_iter);
707 icmap_iter_finalize(old_iter);
708}
709
710/*
711 * Reload configuration file

Calls 6

icmap_iter_initFunction · 0.85
icmap_iter_init_rFunction · 0.85
icmap_iter_nextFunction · 0.85
nullcheck_strcmpFunction · 0.85
icmap_deleteFunction · 0.85
icmap_iter_finalizeFunction · 0.85

Tested by

no test coverage detected