From: <dg...@su...> - 2009-01-05 02:54:04
|
Author: dgollub Date: Mon Jan 5 03:53:36 2009 New Revision: 5008 URL: http://www.opensync.org/changeset/5008 Log: Don't parse/assemble xmlformat in merge/demerge functions. Just pass the pointer and the struct size as output reference. Modified: format-plugins/xmlformat/trunk/src/xmlformat_merge.c Modified: format-plugins/xmlformat/trunk/src/xmlformat_merge.c ============================================================================== --- format-plugins/xmlformat/trunk/src/xmlformat_merge.c Mon Jan 5 02:29:40 2009 (r5007) +++ format-plugins/xmlformat/trunk/src/xmlformat_merge.c Mon Jan 5 03:53:36 2009 (r5008) @@ -34,13 +34,12 @@ osync_trace(TRACE_ENTRY, "%s(%p, %u, %p, %p, %p, %p, %u, %p, %p)", __func__, buf, size, destbuf, destsize, entirebuf, entiresize, caps, error); - xmlformat = osync_xmlformat_parse(buf, size, error); - if (!xmlformat) - goto error; + osync_assert(osync_xmlformat_size() == size); + osync_assert(osync_xmlformat_size() == entiresize); - entire = osync_xmlformat_parse(entirebuf, entiresize, error); - if (!entire) - goto error; + + xmlformat = (OSyncXMLFormat *) buf; + entire = (OSyncXMLFormat *) entirebuf; objtype = osync_xmlformat_get_objtype(xmlformat); @@ -169,10 +168,18 @@ Avoid it! Ticket: #754 */ osync_assert(osync_xmlformat_is_sorted(xmlformat)); - if (!osync_xmlformat_assemble(xmlformat, destbuf, destsize)) - goto error; + if (osync_trace_is_enabled()) { + char *buf; + + if (!osync_xmlformat_assemble(xmlformat, &buf, NULL)) + goto error; + + osync_trace(TRACE_SENSITIVE, "XMLFormat Merged:\n%s ", buf); + osync_free(buf); + } - osync_trace(TRACE_SENSITIVE, "XMLFormat Merged:\n%s ", *destbuf); + *destbuf = (char *) xmlformat; + *destsize = osync_xmlformat_size(); osync_trace(TRACE_EXIT, "%s", __func__); return TRUE; @@ -190,9 +197,9 @@ osync_trace(TRACE_ENTRY, "%s(%p, %u, %p, %p, %p, %p)", __func__, buf, size, destbuf, destsize, caps, error); - xmlformat = osync_xmlformat_parse(buf, size, error); - if (!xmlformat) - goto error; + osync_assert(size == osync_xmlformat_size()); + + xmlformat = (OSyncXMLFormat *) buf; cur_capability = osync_capabilities_get_first(caps, osync_xmlformat_get_objtype(xmlformat)); cur_xmlfield = osync_xmlformat_get_first_field(xmlformat); @@ -270,12 +277,21 @@ end: - if (!osync_xmlformat_assemble(xmlformat, destbuf, destsize)) - goto error; + if (osync_trace_is_enabled()) { + char *buf; + unsigned int bufsize; + + if (!osync_xmlformat_assemble(xmlformat, &buf, &bufsize)) + goto error; + + osync_trace(TRACE_SENSITIVE, "XMLFormat Demerged:\n%s ", buf); + osync_free(buf); + } - osync_trace(TRACE_SENSITIVE, "XMLFormat Demerged:\n%s ", *destbuf); + *destbuf = (char *) xmlformat; + *destsize = osync_xmlformat_size(); - osync_trace(TRACE_EXIT, "%s: ", __func__); + osync_trace(TRACE_EXIT, "%s", __func__); return TRUE; error: |