NdisFreeMemory

VOID
NdisFreeMemory(

IN PVOID VirtualAddress,
IN UINT Length,
IN UINT MemoryFlags
);

NdisFreeMemory releases a block of memory previously allocated with NdisAllocateMemory.

Parameters

VirtualAddress

Points to the base virtual address of the allocated memory. This address was returned by NdisAllocateMemory.

Length

Specifies the size in bytes of the memory block to be released. This parameter must be identical to the Length that was passed to NdisAllocateMemory.

MemoryFlags

Specifies zero or the bitmask originally passed to NdisAllocateMemory for the preceding range, designating the following:

Value Meaning
zero Nonpaged system-space memory
NDIS_MEMORY_CONTIGUOUS Physically contiguous memory
NDIS_MEMORY_NONCACHED Noncached memory

This value must be identical to the MemoryFlags that was passed to NdisAllocateMemory.

Comments

The parameters passed to NdisFreeMemory must be identical to those passed to NdisAllocateMemory when the block of memory was allocated. That is, a caller of NdisFreeMemory cannot release a subrange of the block that was allocated.

Because noncached memory and contiguous memory are seldom released until the allocating NIC driver is unloading, callers of NdisFreeMemory usually are running at IRQL PASSIVE_LEVEL for these types of deallocations.

Callers of NdisFreeMemory can run at IRQL <= DISPATCH_LEVEL when releasing memory that was allocated from nonpaged system space or that was allocated as noncached memory. Callers must be running at IRQL PASSIVE_LEVEL to release contiguous allocations.

See Also

MiniportHalt, NdisAllocateMemory