Allocate Memory in Your NDIS 6.0 Miniport Driver (Compact 2013)

3/26/2014

The NDIS 6.0 NdisAllocateMemoryWithTagPriority function replaces the NDIS 5.xNdisAllocateMemory and NdisAllocateMemoryWithTag functions. In addition to specifying the miniport adapter handle, pool size, and tag, NdisAllocateMemoryWithTagPriority requires that you specify an allocation priority. This allocation priority indicates the importance of the request.

The following table shows which API elements have been renamed and/or changed for NDIS 6.0.

NDIS 5.x

NDIS 6.0

NdisAllocateMemory
NdisAllocateMemoryWithTag

NdisAllocateMemoryWithTagPriority

To update memory allocation functionality for NDIS 6.0

  1. Remove calls to NdisAllocateMemory and NdisAllocateMemoryWithTag.

  2. Use NdisAllocateMemoryWithTagPriority to allocate memory.

The following code example uses NdisAllocateMemoryWithTagPriority to allocate a pool of memory.

Important

For readability, the following code example does not contain security checking orerror handling. Do not use the following code in a production environment.

#define MEM_TAG ((ULONG('DCBA'))
PVOID pMemory = NULL;

pMemory = NdisAllocateMemoryWithTagPriority (
   pMyAdapter->MiniportAdapterHandle,
   (UINT)Size,
   MEM_TAG,
   LowPoolPriority
   );

In the preceding example, NdisAllocateMemoryWithTagPriority allocates Size bytes from the non-paged pool, and this allocation has the memory tag "ABCD". Because the Priority parameter is specified as LowPoolPriority, this request has a lower priority than other memory allocation requests. The allocated memory pool is returned and saved in pMemory for use by the driver.

For more information about NDIS 6.0 memory allocation, see NDIS Memory Interface.

See Also

Concepts

Modify Adapter Initialization Functionality for NDIS 6.0