doc = xmlParseMemory(ha_strdup(buffer), strlen(buffer));
doc = xmlParseMemory(buffer, strlen(buffer));
cib_input_dispatch(IPC_Channel *client, gpointer user_data){	int lpc = 0;	char *buffer = NULL;	xmlDocPtr doc = NULL;	IPC_Message *msg = NULL;	gboolean hack_return_good = TRUE;	xmlNodePtr msg_xml_node = NULL, answer = NULL, root_xml_node = NULL;		FNIN();			while(client->ops->is_message_pending(client)) {		if (client->ch_status == IPC_DISCONNECT) {			/* The message which was pending for us is that			 * the IPC status is now IPC_DISCONNECT */			break;		}		if (client->ops->recv(client, &msg) != IPC_OK) {			perror("Receive failure:");			FNRET(!hack_return_good);		}		if (msg == NULL) {			cl_log(LOG_ERR, "No message this time");			continue;		}		lpc++;		CRM_DEBUG2("Got message [body=%s]", (char*)msg->msg_body);		/* the docs say only do this once, but in their code		 * they do it every time!		 */		xmlInitParser();		buffer = (char*)msg->msg_body;		cl_log(LOG_DEBUG, "Got xml [text=%s]", buffer);		doc = xmlParseMemory(ha_strdup(buffer), strlen(buffer));		CRM_DEBUG("Finished parsing buffer as XML");		if (doc != NULL) {			CRM_DEBUG("About to interrogate xml");			root_xml_node = xmlDocGetRootElement(doc);			CRM_DEBUG("Got the root element");						msg_xml_node =				validate_crm_message(root_xml_node,						     CRM_SYSTEM_CIB,						     NULL,						     XML_MSG_TAG_REQUEST);				if (msg_xml_node != NULL) {				answer = processCibRequest(msg_xml_node);				if (send_ipc_reply(					    client,					    root_xml_node,					    answer) == FALSE)					cl_log(LOG_WARNING,					       "Cib answer could not be sent");				if(answer != NULL)					free_xml(answer);			} else if (root_xml_node != NULL)				cl_log(LOG_INFO,				       "Received a message destined for (%s) "				       "by mistake",				       xmlGetProp(root_xml_node,						  XML_MSG_ATTR_SYSTO));			else				cl_log(LOG_INFO, "Root node was NULL!!");			free_xml(root_xml_node);		} else {			cl_log(LOG_INFO,			       "XML Buffer was not valid...\n Buffer: (%s)",			       buffer);		}		msg->msg_done(msg);	}		CRM_DEBUG2("Processed %d messages", lpc);	if (client->ch_status == IPC_DISCONNECT) {		cl_log(LOG_INFO, "the client has left us: received HUP");		FNRET(!hack_return_good);	}	FNRET(hack_return_good);}