Salome HOME
Correct big bug.
authorAnthony Geay <anthony.geay@edf.fr>
Mon, 26 Jan 2015 16:36:33 +0000 (17:36 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Mon, 26 Jan 2015 16:36:33 +0000 (17:36 +0100)
src/engine/Any.cxx
src/engine/Any.hxx

index e062e0111149f60e74711634007b9937b1122334..eb674034013bfa2becb87ee84f33cfaef32cc8da 100644 (file)
@@ -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;i<sizeof(void *) && isNull;i++)
+    isNull=(data[i]==SeqAlloc::DFT_CHAR_VAR);
+  return isNull;
+}
+
 AtomAny::AtomAny(int val):Any(Runtime::_tc_int)
 {
   _value._i=val;
@@ -275,8 +285,11 @@ void AtomAny::destroyReprAtPlace(char *data, const TypeCode *type)
   DynType typ=type->kind();
   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)
index 3f4560f1b2cf04dcf0c7c253f3fe8d0cdeabab18..00ae71e69b01446448bb5e287fb0027ab869a4c5 100644 (file)
@@ -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<unsigned int> getSetItems() const;
+    public:
       static const char DFT_CHAR_VAR;
     };