diff -r 578be2adaf3e -r 307f4279f433 Adaptation/GUID-0A6C8DB8-ED41-4243-BA96-CA691CF9CD19.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Adaptation/GUID-0A6C8DB8-ED41-4243-BA96-CA691CF9CD19.dita Fri Oct 15 14:32:18 2010 +0100 @@ -0,0 +1,34 @@ + + + + + +Data +BuffersThis document describes how device drivers allocate and access +memory buffers. +
+

Most device drivers need to use memory buffers for I/O operations. +Drivers typically own memory buffers, allocate them, and access them through +pointers. The thread should be in a critical section when it allocates or +de-allocates memory.

// Tx and Rx Buffers +TUInt8* iTxBuffer; +TUInt8* iRxBuffer; // Logical Channel second stage constructor +TInt DExDriverLogicalChannel::DoCreate(TInt /*aUnit*/, const TDesC8* +/*anInfo*/, const TVersion& aVer) + { + ... + // Initialize the Tx Buffer + iTxBuffer = (TUInt8*) Kern::Alloc(KTxBufferSize); + if (!iTxBuffer) + return KErrNoMemory; + ... + }

Memory buffers must be freed when they are not required. +If this is not done, a memory leak occurs.

// Free Tx Buffer +Kern::Free(iTxBuffer)
+
\ No newline at end of file