aboutsummaryrefslogtreecommitdiffstats
path: root/distrib/sdl-1.2.15/src/main/symbian/EKA2/vectorbuffer.cpp
blob: 72c3b3e5c06561d36f51e3405d49c5d07181ef9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
    vectorbuffer.cpp
    yet another circle buffer

    Markus Mertama
*/

#include"vectorbuffer.h"



void VectorPanic(TInt aErr, TInt aLine)
    {
    TBuf<64> b;
    b.Format(_L("vector buffer at % d "), aLine);
    User::Panic(b, aErr);
    }

void TNodeBuffer::TNode::Terminator(TNodeBuffer::TNode* aNode)
    {
    Mem::Copy(iSucc, &aNode, sizeof(TNode*));
    }

TInt TNodeBuffer::TNode::Size() const
    {
    return reinterpret_cast<const TUint8*>(iSucc) - Ptr();
    }

const TUint8*  TNodeBuffer::TNode::Ptr() const
    {
    return reinterpret_cast<const TUint8*>(this) + sizeof(TNode);
    }

TNodeBuffer::TNode*  TNodeBuffer::TNode::Empty(TUint8* aBuffer)
    {
    TNode* node = reinterpret_cast<TNode*>(aBuffer);
    node->iSucc = node + 1;
    return node;
    }

 TNodeBuffer::TNode*  TNodeBuffer::TNode::New(TNode* aPred, const TDesC8& aData)
    {
    TNode* node = aPred->Size() == 0 ? aPred : aPred->iSucc;

    
    TUint8* start = reinterpret_cast<TUint8*>(node) + sizeof(TNode);
    node->iSucc = reinterpret_cast<TNode*>(start + aData.Size());
    node->iSucc->iSucc = NULL; //terminator

    __ASSERT_DEBUG(node->Size() == aData.Size(), VECPANIC(KErrCorrupt));

    Mem::Copy(start, aData.Ptr(), aData.Size());
    return node;
    }