Author: gwinn
Date: Wed Feb 21 04:58:33 2007
New Revision: 509991
URL: http://svn.apache.org/viewvc?view=rev&rev=509991
Log:
Fixes identified by valgrind.
Modified:
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/CopyHelper.cpp
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyImpl.cpp
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyImpl.h
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDODataConverter.cpp
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOXMLWriter.cpp
incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.cpp
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/CopyHelper.cpp
URL:
http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/CopyHelper.cpp?view=diff&rev=509991&r1=509990&r2=509991
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/CopyHelper.cpp
(original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/CopyHelper.cpp Wed
Feb 21 04:58:33 2007
@@ -223,7 +223,7 @@
wchar_t * buf = new wchar_t[siz];
from->getStringValue(index, buf, siz);
to->addString(p, buf, siz);
- delete buf;
+ delete[] buf;
}
}
break;
Modified:
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyImpl.cpp
URL:
http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyImpl.cpp?view=diff&rev=509991&r1=509990&r2=509991
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyImpl.cpp
(original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyImpl.cpp Wed
Feb 21 04:58:33 2007
@@ -68,97 +68,100 @@
// construction by DAS
///////////////////////////////////////////////////////////////////////////
- PropertyImpl::PropertyImpl(const Type& cont,
- const char* inname,
- const TypeImpl& intype,
- bool many ,
- bool ro ,
- bool contain) : containertype(cont), type (intype)
- {
- // name = new char[strlen(inname)+1];
- // strcpy(name,inname);
- if (inname != 0)
- {
- name = inname;
- }
- else
- {
- name.erase();
- }
- defvalue = 0;
- defvaluelength = 0;
- opposite = 0;
- stringdef = 0;
- bisMany = many;
- bisReadOnly = ro;
- bisContainer = contain;
- bDefaulted=false;
- if (contain == false && intype.isDataObjectType())
- {
- bisReference = true;
- }
- else
- {
- bisReference = false;
- }
- }
-
- PropertyImpl::PropertyImpl(const Type& cont,
- const SDOString& inname,
- const TypeImpl& intype,
- bool many,
- bool ro,
- bool contain) :
- containertype(cont),
- name(inname),
- type(intype),
- bisMany(many),
- bisReadOnly(ro),
- bisContainer(contain),
- bDefaulted(false),
- opposite(0),
- stringdef(0),
- defvalue(0),
- defvaluelength(0)
- {
- if (contain == false && intype.isDataObjectType())
- {
- bisReference = true;
- }
- else
- {
- bisReference = false;
- }
- }
+ PropertyImpl::PropertyImpl(const Type& cont,
+ const char* inname,
+ const TypeImpl& intype,
+ bool many ,
+ bool ro ,
+ bool contain) :
+ containertype(cont),
+ type(intype),
+ defvalue(0),
+ defvaluelength(0),
+ opposite(0),
+ stringdef(0),
+ bisMany(many),
+ bisArray(false),
+ bisReadOnly(ro),
+ bisContainer(contain),
+ bDefaulted(false),
+ bisReference(false)
+ {
+ if (inname != 0)
+ {
+ name = inname;
+ }
+ else
+ {
+ name.erase();
+ }
+ if (contain == false && intype.isDataObjectType())
+ {
+ bisReference = true;
+ }
+ }
- PropertyImpl::PropertyImpl(const PropertyImpl& p) :
- type((*(p.getTypeImpl()))),
- containertype(p.getContainingType()),
- name(p.name),
- bisMany(p.bisMany),
- bisReadOnly(p.bisReadOnly),
- bisContainer(p.bisContainer),
- bDefaulted(false),
- opposite(0),
- defvalue(0),
- defvaluelength(0),
- stringdef(0)
- {
- if (bisContainer == false && type.isDataObjectType())
+ PropertyImpl::PropertyImpl(const Type& cont,
+ const SDOString& inname,
+ const TypeImpl& intype,
+ bool many,
+ bool ro,
+ bool contain) :
+ containertype(cont),
+ name(inname),
+ type(intype),
+ bisMany(many),
+ bisArray(false),
+ bisReadOnly(ro),
+ bisContainer(contain),
+ bDefaulted(false),
+ opposite(0),
+ stringdef(0),
+ defvalue(0),
+ defvaluelength(0),
+ bisReference(false)
+ {
+ if (contain == false && intype.isDataObjectType())
{
- bisReference = true;
+ bisReference = true;
}
- else
+ }
+
+ PropertyImpl::PropertyImpl(const PropertyImpl& p) :
+ type((*(p.getTypeImpl()))),
+ containertype(p.getContainingType()),
+ name(p.name),
+ bisMany(p.bisMany),
+ bisArray(false),
+ bisReadOnly(p.bisReadOnly),
+ bisContainer(p.bisContainer),
+ bDefaulted(false),
+ opposite(0),
+ defvalue(0),
+ defvaluelength(0),
+ stringdef(0),
+ bisReference(false)
+ {
+ if (bisContainer == false && type.isDataObjectType())
{
- bisReference = false;
+ bisReference = true;
}
- }
+ }
PropertyImpl::~PropertyImpl()
{
+ // If the default value is an array type then we must use delete[]
+ // otherwise delete
if (defvalue != 0)
{
- delete[] defvalue;
+ if (bisArray)
+ {
+ delete[] defvalue;
+ }
+ else
+ {
+ delete defvalue;
+ }
}
if (stringdef != 0)
{
@@ -498,26 +501,31 @@
void PropertyImpl::setDefaultCString(const char* s)
{
bDefaulted=true;
+ bisArray = true;
defvaluelength = getTypeImpl()->convert(&defvalue,s);
}
void PropertyImpl::setDefaultCString(const SDOString& s)
{
bDefaulted=true;
+ bisArray = true;
defvaluelength = getTypeImpl()->convert(&defvalue, s);
}
void PropertyImpl::setDefaultString( const wchar_t* c , unsigned int
len )
{
bDefaulted=true;
+ bisArray = true;
defvaluelength = getTypeImpl()->convert(&defvalue,c, len);
}
void PropertyImpl::setDefaultBytes( const char* c , unsigned int len )
{
bDefaulted=true;
+ bisArray = true;
defvaluelength = getTypeImpl()->convert(&defvalue,c, len);
}
void PropertyImpl::setDefaultBytes(const SDOString& c , unsigned int len)
{
bDefaulted=true;
+ bisArray = true;
defvaluelength = getTypeImpl()->convert(&defvalue,c, len);
}
void PropertyImpl::setDefaultBoolean( const bool b )
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyImpl.h
URL:
http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyImpl.h?view=diff&rev=509991&r1=509990&r2=509991
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyImpl.h
(original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyImpl.h Wed
Feb 21 04:58:33 2007
@@ -263,6 +263,7 @@
bool bisContainer;
bool bisReference;
bool bisMany;
+ bool bisArray;
bool bDefaulted;
Modified:
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDODataConverter.cpp
URL:
http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDODataConverter.cpp?view=diff&rev=509991&r1=509990&r2=509991
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDODataConverter.cpp
(original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDODataConverter.cpp
Wed Feb 21 04:58:33 2007
@@ -401,7 +401,7 @@
#else
int64_t result = strtoll(tmpstr, NULL, 0);
#endif
- delete tmpstr;
+ delete[] tmpstr;
return result;
}
@@ -464,7 +464,7 @@
}
tmpstr[sourceValue.WideString.length] = 0;
float result = (float) atof(tmpstr);
- delete tmpstr;
+ delete[] tmpstr;
return result;
}
@@ -527,7 +527,7 @@
}
tmpstr[sourceValue.WideString.length] = 0;
double result = atof(tmpstr);
- delete tmpstr;
+ delete[] tmpstr;
return result;
}
Modified:
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOXMLWriter.cpp
URL:
http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOXMLWriter.cpp?view=diff&rev=509991&r1=509990&r2=509991
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOXMLWriter.cpp
(original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOXMLWriter.cpp Wed
Feb 21 04:58:33 2007
@@ -101,7 +101,7 @@
for (int i=0;i<indent;i++)chars[i] = ' ';
chars[indent] = 0;
xmlTextWriterSetIndentString(writer, SDOXMLString(chars));
- delete chars;
+ delete[] chars;
}
else
{
Modified: incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.cpp
URL:
http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.cpp?view=diff&rev=509991&r1=509990&r2=509991
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.cpp Wed Feb 21 04:58:33
2007
@@ -2814,7 +2814,7 @@
wdc = pdg->getCString("string");
fprintf(f, " Expected Wide - got : %s\n",wdc);
- delete wide;
+ delete[] wide;
char* thin = new char[4];
thin[0] = 'T';
@@ -2827,7 +2827,7 @@
const char* dc = pdg->getCString("bytes");
fprintf(f, " Expected Thin - got : %s\n",dc);
- delete thin;
+ delete[] thin;
const char* ps = pdg->getCString("string");
fprintf(f, "Expecting string, got %s\n", ps);
@@ -2870,7 +2870,7 @@
{
fprintf(f, "Wide[%d]=%d\n",i,result[i]);
}
- delete result;
+ delete[] result;
}
@@ -2884,7 +2884,7 @@
{
fprintf(f, "Thin[%d]=%d\n",i,thinresult[i]);
}
- delete thinresult;
+ delete[] thinresult;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]