]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDarrayDictionary.cxx
minor coverity defect: added protection for self-assignment
[u/mrichter/AliRoot.git] / TRD / AliTRDarrayDictionary.cxx
index c8e83f889e3ba3c45d46f717a42e47b1861d8811..dcd7e82f4b1bf5e690252b455be4f5f20fa70b8b 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "AliTRDarrayDictionary.h"
 #include "AliTRDfeeParam.h"
+#include "AliLog.h"
 
 ClassImp(AliTRDarrayDictionary)
 
@@ -64,7 +65,6 @@ AliTRDarrayDictionary::AliTRDarrayDictionary(Int_t nrow, Int_t ncol, Int_t ntime
                      ,fNDdim(0)
                      ,fDictionary(0)
                       ,fFlag(kFALSE)
-
 {
   //
   // AliTRDarrayDictionary contructor
@@ -265,8 +265,7 @@ void AliTRDarrayDictionary::Compress()
       delete [] longArr;
       longArr=0;
     }
-  fFlag=kTRUE; // flag to signal compression
-
+  fFlag=kFALSE; // This way it can be expanded afterwards
 }
 
 //________________________________________________________________________________
@@ -276,8 +275,19 @@ void AliTRDarrayDictionary::Expand()
   //  Expand the array
   //  
 
+  if(fNDdim==0)
+    {
+      AliError("Called expand with dimension zero");
+      return;    
+    }
+
+
   Int_t dimexp=0;
-  if(!IsCompressed())
+  
+//   if(WasExpandCalled()) 
+//     return;
+
+  if(fNDdim==fNrow*fNumberOfChannels*fNtime)
     return;
 
   if(fDictionary&&fNDdim==1)
@@ -289,6 +299,7 @@ void AliTRDarrayDictionary::Expand()
       fNDdim = dimexp;
       // Re-initialize the array
       memset(fDictionary,-1,sizeof(Int_t)*dimexp);
+      fFlag=kTRUE; // Not expand again
       return;
     }
 
@@ -322,11 +333,10 @@ void AliTRDarrayDictionary::Expand()
       Int_t contaexp =0;    
       Int_t h=0;
       Int_t* bufferE = new Int_t[dimexp];
-      memset(bufferE,-1,sizeof(Int_t)*dimexp);
 
       if(bufferE)
        {
-
+         memset(bufferE,-1,sizeof(Int_t)*dimexp);
           for(Int_t i=0; i<dimexp; i++)
             {
               if(fDictionary[contaexp]>=-1)  
@@ -351,8 +361,7 @@ void AliTRDarrayDictionary::Expand()
     {
       delete [] longArr; 
     }
-
-  fFlag=kFALSE; // flag to signal that is not compressed anymore
+  fFlag=kTRUE; // Not expand again
 
 }
 //________________________________________________________________________________