Bug fix. Sorting out the issue with the ownership of the DATE event in the memory...
authorcvetan <cvetan@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 17 Sep 2009 12:39:10 +0000 (12:39 +0000)
committercvetan <cvetan@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 17 Sep 2009 12:39:10 +0000 (12:39 +0000)
RAW/AliRawReaderDate.cxx
RAW/AliRawReaderDate.h

index 60dd68c..8553e19 100644 (file)
@@ -34,9 +34,9 @@ ClassImp(AliRawReaderDate)
 
 AliRawReaderDate::AliRawReaderDate(
 #ifdef ALI_DATE
-                                  void* event
+                                  void* event, Bool_t owner
 #else
-                                  void* /* event */
+                                  void* /* event */, Bool_t owner
 #endif
                                   ) :
   fFile(NULL),
@@ -44,7 +44,8 @@ AliRawReaderDate::AliRawReaderDate(
   fSubEvent(NULL),
   fEquipment(NULL),
   fPosition(NULL),
-  fEnd(NULL)
+  fEnd(NULL),
+  fOwner(owner)
 {
 // create an object to read digits from the given date event
 
@@ -68,7 +69,8 @@ AliRawReaderDate::AliRawReaderDate(
   fSubEvent(NULL),
   fEquipment(NULL),
   fPosition(NULL),
-  fEnd(NULL)
+  fEnd(NULL),
+  fOwner(kTRUE)
 {
 // create an object to read digits from the given date event
 
@@ -107,7 +109,8 @@ AliRawReaderDate::AliRawReaderDate(const AliRawReaderDate& rawReader) :
   fSubEvent(rawReader.fSubEvent),
   fEquipment(rawReader.fEquipment),
   fPosition(rawReader.fPosition),
-  fEnd(rawReader.fEnd)
+  fEnd(rawReader.fEnd),
+  fOwner(rawReader.fOwner)
 
 {
 // copy constructor
@@ -129,7 +132,7 @@ AliRawReaderDate::~AliRawReaderDate()
 // destructor
 
 #ifdef ALI_DATE
-  if (fEvent) delete[] fEvent;
+  if (fEvent && fOwner) delete[] fEvent;
   if (fFile) {
     fclose(fFile);
   }
@@ -651,7 +654,7 @@ AliRawReader* AliRawReaderDate::CloneSingleEvent() const
     if (evSize) {
       UChar_t *newEvent = new UChar_t[evSize];
       memcpy(newEvent,fEvent,evSize);
-      return new AliRawReaderDate((void *)newEvent);
+      return new AliRawReaderDate((void *)newEvent,kTRUE);
     }
   }
 #else
index 3a5011a..060929d 100644 (file)
@@ -19,7 +19,7 @@ struct equipmentHeaderStruct;
 
 class AliRawReaderDate: public AliRawReader {
   public :
-    AliRawReaderDate(void* event);
+    AliRawReaderDate(void* event, Bool_t owner = kFALSE);
     AliRawReaderDate(const char* fileName, Int_t eventNumber = -1);
     virtual ~AliRawReaderDate();
 
@@ -63,6 +63,8 @@ class AliRawReaderDate: public AliRawReader {
     UChar_t*         fPosition;     // current position in the raw data
     UChar_t*         fEnd;          // end position of the current data block
 
+    Bool_t           fOwner;        // is raw-reader owner of the raw event or not
+
   private:
     AliRawReaderDate(const AliRawReaderDate& rawReader);
     AliRawReaderDate& operator = (const AliRawReaderDate& rawReader);