diff -r 89d6a7a84779 -r 25a17d01db0c Symbian3/PDK/Source/GUID-0A6C8DB8-ED41-4243-BA96-CA691CF9CD19.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/PDK/Source/GUID-0A6C8DB8-ED41-4243-BA96-CA691CF9CD19.dita Fri Jan 22 18:26:19 2010 +0000 @@ -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