From: Anthony Geay Date: Mon, 26 Jan 2015 16:36:33 +0000 (+0100) Subject: Correct big bug. X-Git-Tag: V7_6_0a1~11 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6c55ebb7ff8b452d8e16b38e5cfc091cd8e2c264;p=modules%2Fyacs.git Correct big bug. --- diff --git a/src/engine/Any.cxx b/src/engine/Any.cxx index e062e0111..eb6740340 100644 --- a/src/engine/Any.cxx +++ b/src/engine/Any.cxx @@ -87,6 +87,16 @@ Any::~Any() _type->decrRef(); } +bool Any::IsNull(char *data) +{ + if(!data) + return true; + bool isNull(true); + for(std::size_t i=0;ikind(); if(typ==String) { - void **tmp=(void **)data; - delete ((StringOnHeap *)(*tmp)); + if(!Any::IsNull(data)) + { + void **tmp=(void **)data; + delete ((StringOnHeap *)(*tmp)); + } } } @@ -539,7 +552,7 @@ void SequenceAny::putReprAtPlace(char *data, const char *src, const TypeCode *ty void SequenceAny::destroyReprAtPlace(char *data, const TypeCode *type) { void **tmp=(void **) data; - if(*tmp) + if(!Any::IsNull(data)) ((SequenceAny *)(*tmp))->decrRef(); //((SequenceAny *)data)->~SequenceAny(); } @@ -716,7 +729,7 @@ ArrayAny::ArrayAny(const TypeCode *typeOfContent, unsigned int lgth):ComposedAny { _data=new char[_type->getSizeInByteOfAnyReprInSeq()]; for(unsigned int i=0;i<_type->getSizeInByteOfAnyReprInSeq();i++) - _data[i]='\0'; + _data[i]=SeqAlloc::DFT_CHAR_VAR; } ArrayAny::ArrayAny(char *data, TypeCodeArray * type):ComposedAny(type,false),_data(0) @@ -984,7 +997,7 @@ StructAny::StructAny(TypeCodeStruct *type):ComposedAny(type,false) { _data=new char[_type->getSizeInByteOfAnyReprInSeq()]; for(unsigned int i=0;i<_type->getSizeInByteOfAnyReprInSeq();i++) - _data[i]='\0'; + _data[i]=SeqAlloc::DFT_CHAR_VAR; } StructAny::StructAny(const StructAny& other):ComposedAny(other) diff --git a/src/engine/Any.hxx b/src/engine/Any.hxx index 3f4560f1b..00ae71e69 100644 --- a/src/engine/Any.hxx +++ b/src/engine/Any.hxx @@ -91,7 +91,8 @@ namespace YACS Any(TypeCode* type); Any(const Any& other); virtual void putMyReprAtPlace(char *data) const = 0; - static AnyPtr buildAnyFromCoarseData(char *data, TypeCode* type); //Factory Method + //static AnyPtr buildAnyFromCoarseData(char *data, TypeCode* type); //Factory Method + static bool IsNull(char *data); protected: TypeCode* _type; }; @@ -163,6 +164,7 @@ namespace YACS void deallocate(char *pt); unsigned int size() const; std::vector getSetItems() const; + public: static const char DFT_CHAR_VAR; };