Share via


NdisFreeMemory (NDIS 5.1) function

Note   NDIS 5. x has been deprecated and is superseded by NDIS 6. x. For new NDIS driver development, see Network Drivers Starting with Windows Vista. For information about porting NDIS 5. x drivers to NDIS 6. x, see Porting NDIS 5.x Drivers to NDIS 6.0.

NdisFreeMemory releases a block of memory previously allocated with NdisAllocateMemory or NdisAllocateMemoryWithTag.

Syntax

VOID NdisFreeMemory(
  _In_ PVOID VirtualAddress,
  _In_ UINT  Length,
  _In_ UINT  MemoryFlags
);

Parameters

  • VirtualAddress [in]
    Pointer to the base virtual address of the allocated memory. This address was returned by NdisAllocateMemory or NdisAllocateMemoryWithTag.

  • Length [in]
    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. However, if the memory was allocated with NdisAllocateMemoryWithTag or the MemoryFlags parameter is zero, this parameter is ignored.

  • MemoryFlags [in]
    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 zero if the memory was allocated with NdisAllocateMemoryWithTag. This value must be identical to the MemoryFlags that was passed to NdisAllocateMemory.

Return value

None

Remarks

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, a caller of NdisFreeMemory usually is running at IRQL = PASSIVE_LEVEL for these types of deallocations. In any case:

  • When releasing contiguous memory, a caller of NdisFreeMemory must be running at IRQL = PASSIVE_LEVEL

  • When releasing noncached memory, a caller of NdisFreeMemory must be running at IRQL < DISPATCH_LEVEL

  • When releasing memory that is neither contiguous nor noncached, a caller of NdisFreeMemory must be running at IRQL <= DISPATCH_LEVEL

Requirements

Target platform

Universal

Version

See NdisFreeMemory.

Header

Ndis.h (include Ndis.h)

Library

Ndis.lib

IRQL

See Remarks section.

See also

MiniportHalt

NdisAllocateMemory

NdisAllocateMemoryWithTag

 

 

Send comments about this topic to Microsoft