Home | History | Annotate | Download | only in EKA2
      1 /*
      2     vectorbuffer.cpp
      3     yet another circle buffer
      4 
      5     Markus Mertama
      6 */
      7 
      8 #include"vectorbuffer.h"
      9 
     10 
     11 
     12 void VectorPanic(TInt aErr, TInt aLine)
     13     {
     14     TBuf<64> b;
     15     b.Format(_L("vector buffer at % d "), aLine);
     16     User::Panic(b, aErr);
     17     }
     18 
     19 void TNodeBuffer::TNode::Terminator(TNodeBuffer::TNode* aNode)
     20     {
     21     Mem::Copy(iSucc, &aNode, sizeof(TNode*));
     22     }
     23 
     24 TInt TNodeBuffer::TNode::Size() const
     25     {
     26     return reinterpret_cast<const TUint8*>(iSucc) - Ptr();
     27     }
     28 
     29 const TUint8*  TNodeBuffer::TNode::Ptr() const
     30     {
     31     return reinterpret_cast<const TUint8*>(this) + sizeof(TNode);
     32     }
     33 
     34 TNodeBuffer::TNode*  TNodeBuffer::TNode::Empty(TUint8* aBuffer)
     35     {
     36     TNode* node = reinterpret_cast<TNode*>(aBuffer);
     37     node->iSucc = node + 1;
     38     return node;
     39     }
     40 
     41  TNodeBuffer::TNode*  TNodeBuffer::TNode::New(TNode* aPred, const TDesC8& aData)
     42     {
     43     TNode* node = aPred->Size() == 0 ? aPred : aPred->iSucc;
     44 
     45 
     46     TUint8* start = reinterpret_cast<TUint8*>(node) + sizeof(TNode);
     47     node->iSucc = reinterpret_cast<TNode*>(start + aData.Size());
     48     node->iSucc->iSucc = NULL; //terminator
     49 
     50     __ASSERT_DEBUG(node->Size() == aData.Size(), VECPANIC(KErrCorrupt));
     51 
     52     Mem::Copy(start, aData.Ptr(), aData.Size());
     53     return node;
     54     }
     55 
     56 
     57 
     58 
     59 
     60 
     61 
     62