]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Fixing compilation problem. fBlock was not dereferenced in BlockHeader() method.
authorszostak <szostak@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 1 Jul 2007 06:03:26 +0000 (06:03 +0000)
committerszostak <szostak@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 1 Jul 2007 06:03:26 +0000 (06:03 +0000)
HLT/MUON/AliHLTMUONDataBlockReader.h
HLT/MUON/AliHLTMUONDataBlockWriter.h

index 7d1b608e623d567f82bdd47cc2b72b21ef8b36d4..5b69058aa854d00e6ac81166f79d198d1d65af5e 100644 (file)
@@ -100,6 +100,8 @@ public:
        bool BufferSizeOk() const
        {
                // The block size must be at least sizeof(DataBlockType) bytes.
+               // Do not try read the header otherwise, because we could get a
+               // seg fault.
                if (fSize < sizeof(DataBlockType)) return false;
 
                // Now check if the size of the data block corresponds to the
@@ -121,7 +123,7 @@ public:
         */
        const DataBlockType& BlockHeader() const
        {
-               return fBlock;
+               return *fBlock;
        }
 
        /**
@@ -160,6 +162,17 @@ public:
         */
        const DataElementType* GetArray() const { return fData; }
 
+       /**
+        * Calculates the number of bytes used for the data block in the buffer.
+        * This value should be the same as what is returned by BufferSize()
+        * unless too much buffer space was allocated.
+        */
+       AliHLTUInt32_t BytesUsed() const
+       {
+               assert( sizeof(DataElementType) == fBlock->fHeader.fRecordWidth);
+               return sizeof(DataBlockType) + Nentries() * sizeof(DataElementType);
+       }
+
        AliHLTUInt32_t BufferSize() { return fSize; }
        
 private:
index 06c2f950469297cafe54ae166b30280840e85078..73c7e1c9e6f5bf8600f07c46cfeb540c3e9b6af7 100644 (file)
@@ -152,12 +152,12 @@ public:
         */
        DataBlockType& BlockHeader()
        {
-               return fBlock;
+               return *fBlock;
        }
        
        const DataBlockType& BlockHeader() const
        {
-               return fBlock;
+               return *fBlock;
        }
        
        /**
@@ -184,6 +184,7 @@ public:
        {
                if (n * sizeof(DataElementType) > fMaxArraySize) return false;
                fBlock->fHeader.fNrecords = n;
+               return true;
        }
 
        /**
@@ -241,10 +242,7 @@ public:
         */
        AliHLTUInt32_t BytesUsed() const
        {
-               assert( Nentries() * sizeof(DataElementType)
-                       == Nentries() * fBlock->fHeader.fRecordWidth
-               );
-               
+               assert( sizeof(DataElementType) == fBlock->fHeader.fRecordWidth);
                return sizeof(DataBlockType) + Nentries() * sizeof(DataElementType);
        }