cvs: pecl /sdo/commonj/sdo SDOXMLString.cpp

From: Date: Thu, 12 Oct 2006 12:20:53 +0000
Subject: cvs: pecl /sdo/commonj/sdo SDOXMLString.cpp
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-6482@lists.php.net to get a copy of this message
cem Thu Oct 12 12:20:53 2006 UTC Modified files: /pecl/sdo/commonj/sdo SDOXMLString.cpp Log: Patch for memory leak - #462804 Wed Oct 11 06:41:17 PDT 2006 robbinspg TUSCANY-825 Fix memory leak when substringing SDOXMLString http://cvs.php.net/viewvc.cgi/pecl/sdo/commonj/sdo/SDOXMLString.cpp?r1=1.5&r2=1.6&diff_format=u Index: pecl/sdo/commonj/sdo/SDOXMLString.cpp diff -u pecl/sdo/commonj/sdo/SDOXMLString.cpp:1.5 pecl/sdo/commonj/sdo/SDOXMLString.cpp:1.6 --- pecl/sdo/commonj/sdo/SDOXMLString.cpp:1.5 Thu Sep 28 19:24:41 2006 +++ pecl/sdo/commonj/sdo/SDOXMLString.cpp Thu Oct 12 12:20:53 2006 @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Rev$ $Date: 2006/09/28 19:24:41 $ */ +/* $Rev$ $Date: 2006/10/12 12:20:53 $ */ #include "commonj/sdo/SDOXMLString.h" #include <iostream> @@ -27,32 +27,32 @@ { namespace sdo { - + SDOXMLString::SDOXMLString() : xmlForm(0) { } - + SDOXMLString::SDOXMLString(const xmlChar* xmlString) { xmlForm = xmlStrdup(xmlString); } - + SDOXMLString::SDOXMLString(const char* localString) { xmlForm = xmlCharStrdup(localString); } - + SDOXMLString::SDOXMLString(const SDOXMLString& str) { xmlForm = xmlStrdup(str.xmlForm); } - + SDOXMLString::SDOXMLString(const xmlChar* str, int start, int len) { xmlForm = xmlStrsub(str, start, len); } - + SDOXMLString& SDOXMLString::operator=(const SDOXMLString& str) { if (this != &str) @@ -77,18 +77,18 @@ xmlForm = xmlStrncat(xmlForm, str.xmlForm, xmlStrlen(str.xmlForm)); return *this; } - + SDOXMLString::~SDOXMLString() { release(); } - + void SDOXMLString::release() { if (xmlForm) xmlFree((void*)xmlForm); } - + bool SDOXMLString::operator< (const SDOXMLString& str) const { if (xmlStrcmp(xmlForm, str.xmlForm) <0) @@ -96,7 +96,7 @@ else return false; } - + bool SDOXMLString::operator==(const SDOXMLString& str) const { if (xmlStrEqual(xmlForm, str.xmlForm)) @@ -109,12 +109,12 @@ { return equals(str.xmlForm); } - + bool SDOXMLString::equals(const char* localString) const { return equals(SDOXMLString(localString)); } - + bool SDOXMLString::equals(const xmlChar* xmlString) const { @@ -123,17 +123,17 @@ else return false; } - + bool SDOXMLString::equalsIgnoreCase(const SDOXMLString& str) const { return equalsIgnoreCase(str.xmlForm); } - + bool SDOXMLString::equalsIgnoreCase(const char* localString) const { return equalsIgnoreCase(SDOXMLString(localString)); } - + bool SDOXMLString::equalsIgnoreCase(const xmlChar* xmlString) const { @@ -142,15 +142,15 @@ else return false; } - - + + std::ostream& operator<<(std::ostream& output, const SDOXMLString& str) { if (str.xmlForm) output << str.xmlForm; return output; } - + bool SDOXMLString::isNull() const { if (xmlForm) @@ -179,10 +179,10 @@ { return -1; } - + return int(loc-xmlForm); } - + int SDOXMLString::lastIndexOf(const char ch) const { const xmlChar* index = 0; @@ -192,30 +192,30 @@ index = loc; loc = xmlStrchr(loc+1, ch); } - + if (index == 0) return -1; return int(index-xmlForm); } - + SDOXMLString SDOXMLString::substring(int start, int length) const { if (length >0) { - return xmlStrsub(xmlForm, start, length); + return SDOXMLString(xmlForm, start, length); } else return SDOXMLString(); } - + SDOXMLString SDOXMLString::substring(int start) const { - - return xmlStrsub(xmlForm, start, xmlStrlen(xmlForm) - start); + + return SDOXMLString(xmlForm, start, xmlStrlen(xmlForm) - start); } - - + + } // End - namespace sdo } // End - namespace commonj

« previous php.pecl.cvs (#6482) next »