if (dest != NULL) { unlink_xml_node(dest); xmlFreeNode(dest); }
cib_delete_node(dest);
updateResource(xmlNodePtr cib, cibResource *anXmlNode){    CRM_DEBUG2("Updating " XML_CIB_TAG_RESOURCE " (%s)...", ID(anXmlNode));        xmlNodePtr res = findResource(cib, ID(anXmlNode));    if (res == NULL) {		CRM_DEBUG2("Update: " XML_CIB_TAG_RESOURCE " (%s) did not exist, adding.",				   ID(anXmlNode));		addResource(cib, anXmlNode);    } else {		copy_in_properties(anXmlNode, res);			CRM_DEBUG2("Update: Copying in children for " XML_CIB_TAG_RESOURCE " (%s).",				   ID(anXmlNode));		xmlNodePtr iter = anXmlNode->children;		while(iter != NULL) {			if (strcmp(XML_CIB_ATTR_NODEREF, iter->name) == 0) {				const char *action = xmlGetProp(iter, XML_CIB_ATTR_ACTION);				const char *id = ID(iter);				xmlNodePtr dest = find_entity(res, XML_CIB_ATTR_NODEREF, id, FALSE);						if (dest != NULL) {					unlink_xml_node(dest);					xmlFreeNode(dest);				}						if (strcmp("add", action) == 0) {					xmlNodePtr node_copy = xmlCopyNode(iter, 1);					// remove the action property first					xmlUnsetProp(node_copy, XML_CIB_ATTR_ACTION);										xmlAddChild(res, node_copy);				}			}		}    }    FNRET(0);    }