3 yet another circle buffer
8 #include"vectorbuffer.h"
12 void VectorPanic(TInt aErr, TInt aLine)
15 b.Format(_L("vector buffer at % d "), aLine);
19 void TNodeBuffer::TNode::Terminator(TNodeBuffer::TNode* aNode)
21 Mem::Copy(iSucc, &aNode, sizeof(TNode*));
24 TInt TNodeBuffer::TNode::Size() const
26 return reinterpret_cast<const TUint8*>(iSucc) - Ptr();
29 const TUint8* TNodeBuffer::TNode::Ptr() const
31 return reinterpret_cast<const TUint8*>(this) + sizeof(TNode);
34 TNodeBuffer::TNode* TNodeBuffer::TNode::Empty(TUint8* aBuffer)
36 TNode* node = reinterpret_cast<TNode*>(aBuffer);
37 node->iSucc = node + 1;
41 TNodeBuffer::TNode* TNodeBuffer::TNode::New(TNode* aPred, const TDesC8& aData)
43 TNode* node = aPred->Size() == 0 ? aPred : aPred->iSucc;
46 TUint8* start = reinterpret_cast<TUint8*>(node) + sizeof(TNode);
47 node->iSucc = reinterpret_cast<TNode*>(start + aData.Size());
48 node->iSucc->iSucc = NULL; //terminator
50 __ASSERT_DEBUG(node->Size() == aData.Size(), VECPANIC(KErrCorrupt));
52 Mem::Copy(start, aData.Ptr(), aData.Size());