Update contrib.
1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #include <kernel/kernel.h>
17 #include "d_buffer_manager.h"
19 using namespace Debug;
21 // Global buffer manager
22 DBufferManager TheDBufferManager;
24 DBufferManager::DBufferManager()
28 DBufferManager::~DBufferManager()
30 for(TInt i=0; i<iBuffers.Count(); i++)
32 if(iBuffers[i].iSize>0 && iBuffers[i].iValue)
34 Kern::Free((TAny*)iBuffers[i].iValue);
42 * Creates a buffer and adds it to the buffer manager
43 * @param aBufferDetails Contains the size and tag ID of the buffer to be created and the location
44 * in which the resulting buffer is created
45 * @return One of the System wide error codes
47 TInt DBufferManager::CreateBuffer(TTag& aBufferDetails)
49 if(aBufferDetails.iType != ETagTypePointer)
53 if(aBufferDetails.iSize == 0)
58 for(TInt i=0; i<iBuffers.Count(); i++)
60 if(iBuffers[i].iTagId == aBufferDetails.iTagId)
62 return KErrAlreadyExists;
66 TAny* buffer = Kern::AllocZ(aBufferDetails.iSize);
72 aBufferDetails.iValue = (TUint32)buffer;
73 if(KErrNone != iBuffers.Append(aBufferDetails))
83 * Retrieves buffer details for a given tag
84 * @param aTag The tag for which to get buffer details
85 * @return One of the System wide error codes
87 TInt DBufferManager::GetBufferDetails(const TBufferType aBufferType, TTag& aTag) const
89 for(TInt i=0; i<iBuffers.Count(); i++)
91 if(iBuffers[i].iTagId == aBufferType)
98 aTag.iTagId = aBufferType;
99 aTag.iType = ETagTypePointer;