ULONG DerefPacket(
IN PNDIS_PACKET pPacket
)
{
PRSVD pRsvd = (PRSVD)(pPacket->ProtocolReserved);
PNDIS_BUFFER pBuffer;
PUCHAR pPktData;
ULONG Result, Len;
KdPrint(("DerefPacket,pRsvd->RefCount=%d\n",pRsvd->RefCount));
if ((Result = InterlockedDecrement(&pRsvd->RefCount)) == 0) {
//
// when refcount reaches 0, no one will use this packet any more, i.e., no one will
// increase refcount again. so i can here boldly release it.
//
NdisUnchainBufferAtFront( pPacket, &pBuffer);
NdisQueryBufferSafe( pBuffer, &pPktData, &Len, NormalPagePriority)
// free pkt resources
NdisFreeToNPagedLookasideList( &PktDataLookasideList, pPktData);
NdisFreeBuffer(pBuffer);
NdisFreePacket(pPacket);
}
return Result;
}
RefBindingCtxt代码如下:
ULONG
RefBindingCtxt(
IN PADAPT pAdapt
)
{
return InterlockedIncrement(&pAdapt->RefCount);
}
DerefBindingCtxt代码如下:
ULONG
DerefBindingCtxt(
IN PADAPT pAdapt
)
{
return InterlockedDecrement(&pAdapt->RefCount);
}