--- parser3/src/classes/xdoc.C 2004/02/17 15:02:15 1.135 +++ parser3/src/classes/xdoc.C 2004/02/17 15:08:51 1.137 @@ -9,7 +9,7 @@ #ifdef XML -static const char * const IDENT_XDOC_C="$Date: 2004/02/17 15:02:15 $"; +static const char * const IDENT_XDOC_C="$Date: 2004/02/17 15:08:51 $"; #include "gdome.h" #include "libxml/tree.h" @@ -54,41 +54,6 @@ public: DECLARE_CLASS_VAR(xdoc, new MXdoc, 0); -// helper classes - -class xmlOutputBuffer_auto_ptr { -public: - explicit xmlOutputBuffer_auto_ptr(xmlOutputBuffer *_APtr = 0) - : _Owns(_APtr != 0), _Ptr(_APtr) {} - xmlOutputBuffer_auto_ptr(const xmlOutputBuffer_auto_ptr& _Y) - : _Owns(_Y._Owns), _Ptr(_Y.release()) {} - xmlOutputBuffer_auto_ptr& operator=(const xmlOutputBuffer_auto_ptr& _Y) - {if (this != &_Y) - {if (_Ptr != _Y.get()) - {if (_Owns && _Ptr) - xmlOutputBufferClose(_Ptr); - _Owns = _Y._Owns; } - else if (_Y._Owns) - _Owns = true; - _Ptr = _Y.release(); } - return (*this); } - ~xmlOutputBuffer_auto_ptr() - {if (_Owns && _Ptr) - xmlOutputBufferClose(_Ptr); } - xmlOutputBuffer& operator*() const - {return (*get()); } - xmlOutputBuffer *operator->() const - {return (get()); } - xmlOutputBuffer *get() const - {return (_Ptr); } - xmlOutputBuffer *release() const - {((xmlOutputBuffer_auto_ptr *)this)->_Owns = false; - return (_Ptr); } -private: - bool _Owns; - xmlOutputBuffer *_Ptr; -}; - class xsltTransformContext_auto_ptr { public: explicit xsltTransformContext_auto_ptr(xsltTransformContext *_APtr = 0) @@ -636,6 +601,12 @@ pa_xsltSaveResultToMem( ||xmlStrEqual(method, (const xmlChar *) "xhtml"))) { if (indent == -1) indent = 1; + // + // * xmlDocDumpFormatMemoryEnc: + // Note it is up to the caller of this function to free the + // allocated memory with xmlFree() + // + // we wont free anything, and wont copy that data anymore [already done inside and zeroterminated] xmlDocDumpFormatMemoryEnc(result, &doc_txt_ptr, &doc_txt_len, (const char *) encoding, indent); } else if ((method != NULL) && @@ -739,13 +710,12 @@ pa_xsltSaveResultToMem( doc_txt_len=buf->buffer->use; doc_txt_ptr=buf->buffer->content; } - } - if(doc_txt_ptr && doc_txt_len) - doc_txt_ptr=BAD_CAST pa_strdup((const char*)doc_txt_ptr, doc_txt_len); + if(doc_txt_ptr && doc_txt_len) + doc_txt_ptr=BAD_CAST pa_strdup((const char*)doc_txt_ptr, doc_txt_len); - if(buf) xmlOutputBufferClose(buf); + } } struct Xdoc2buf_result {