]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliFMDFloatMap.cxx
Fix fixed-string length bug
[u/mrichter/AliRoot.git] / STEER / AliFMDFloatMap.cxx
index 859dd7fb7493f2ec680546d3424dcb127e307220..86967661e0a629b446fb8f9a7cc6d177bacf08a3 100755 (executable)
@@ -62,7 +62,7 @@ AliFMDFloatMap::AliFMDFloatMap(Int_t maxDet,
   //   maxRing Maximum number of rings per detector
   //   maxSec  Maximum number of sectors per ring
   //   maxStr  Maximum number of strips per sector
-  Reset();
+  Reset(0);
 }
 
 //__________________________________________________________
@@ -70,14 +70,22 @@ AliFMDFloatMap&
 AliFMDFloatMap::operator=(const AliFMDFloatMap& other)
 {
   // Assignment operator 
-  fMaxDetectors = other.fMaxDetectors;
-  fMaxRings     = other.fMaxRings;
-  fMaxSectors   = other.fMaxSectors;
-  fMaxStrips    = other.fMaxStrips;
-  fTotal        = fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips;
-  if (fData) delete [] fData;
-  fData = new Float_t[fTotal];
-  for (Int_t i = 0; i < fTotal; i++) fData[i] = other.fData[i];
+  if(&other != this){
+    if(fMaxDetectors!= other.fMaxDetectors||
+       fMaxRings    != other.fMaxRings||
+       fMaxSectors  != other.fMaxSectors||
+       fMaxStrips   != other.fMaxStrips){
+      // allocate new memory only if the array size is different....
+      fMaxDetectors = other.fMaxDetectors;
+      fMaxRings     = other.fMaxRings;
+      fMaxSectors   = other.fMaxSectors;
+      fMaxStrips    = other.fMaxStrips;
+      fTotal        = fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips;
+      if (fData) delete [] fData;
+      fData = new Float_t[fTotal];
+    }
+    for (Int_t i = 0; i < fTotal; i++) fData[i] = other.fData[i];
+  }
   return *this;
 }