[AFD] Introduce and use pool tags. Thanks go to Arty for assisting me with this....
[reactos.git] / drivers / network / afd / afd / context.c
index eb9cf7f..6a72a1c 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id$
+/*
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
  * FILE:             drivers/net/afd/afd/context.c
@@ -7,25 +7,28 @@
  * UPDATE HISTORY:
  * 20040708 Created
  */
+
 #include "afd.h"
 
 NTSTATUS NTAPI
 AfdGetContext( PDEVICE_OBJECT DeviceObject, PIRP Irp,
-              PIO_STACK_LOCATION IrpSp ) {
+               PIO_STACK_LOCATION IrpSp ) {
     NTSTATUS Status = STATUS_INVALID_PARAMETER;
     PFILE_OBJECT FileObject = IrpSp->FileObject;
     PAFD_FCB FCB = FileObject->FsContext;
     UINT ContextSize = IrpSp->Parameters.DeviceIoControl.OutputBufferLength;
 
+    UNREFERENCED_PARAMETER(DeviceObject);
+
     if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp );
 
     if( FCB->ContextSize < ContextSize ) ContextSize = FCB->ContextSize;
 
     if( FCB->Context ) {
-       RtlCopyMemory( Irp->UserBuffer,
-                      FCB->Context,
-                      ContextSize );
-       Status = STATUS_SUCCESS;
+        RtlCopyMemory( Irp->UserBuffer,
+                       FCB->Context,
+                       ContextSize );
+        Status = STATUS_SUCCESS;
     }
 
     AFD_DbgPrint(MID_TRACE,("Returning %x\n", Status));
@@ -35,11 +38,13 @@ AfdGetContext( PDEVICE_OBJECT DeviceObject, PIRP Irp,
 
 NTSTATUS NTAPI
 AfdGetContextSize( PDEVICE_OBJECT DeviceObject, PIRP Irp,
-                  PIO_STACK_LOCATION IrpSp )
+                   PIO_STACK_LOCATION IrpSp )
 {
     PFILE_OBJECT FileObject = IrpSp->FileObject;
     PAFD_FCB FCB = FileObject->FsContext;
 
+    UNREFERENCED_PARAMETER(DeviceObject);
+
     if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp );
 
     if (IrpSp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(ULONG))
@@ -57,31 +62,34 @@ AfdGetContextSize( PDEVICE_OBJECT DeviceObject, PIRP Irp,
 
 NTSTATUS NTAPI
 AfdSetContext( PDEVICE_OBJECT DeviceObject, PIRP Irp,
-              PIO_STACK_LOCATION IrpSp ) {
+               PIO_STACK_LOCATION IrpSp ) {
     PFILE_OBJECT FileObject = IrpSp->FileObject;
     PAFD_FCB FCB = FileObject->FsContext;
-    PVOID Context = LockRequest(Irp, IrpSp);
+    PVOID Context = LockRequest(Irp, IrpSp, FALSE, NULL);
+
+    UNREFERENCED_PARAMETER(DeviceObject);
 
     if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp );
-    
+
     if (!Context)
         return UnlockAndMaybeComplete(FCB, STATUS_NO_MEMORY, Irp, 0);
 
     if( FCB->Context ) {
-       ExFreePool( FCB->Context );
-       FCB->ContextSize = 0;
+        ExFreePoolWithTag(FCB->Context, TAG_AFD_SOCKET_CONTEXT);
+        FCB->ContextSize = 0;
     }
 
-    FCB->Context = ExAllocatePool( PagedPool,
-                                  IrpSp->Parameters.DeviceIoControl.InputBufferLength );
+    FCB->Context = ExAllocatePoolWithTag(PagedPool,
+                                         IrpSp->Parameters.DeviceIoControl.InputBufferLength,
+                                         TAG_AFD_SOCKET_CONTEXT);
 
     if( !FCB->Context ) return UnlockAndMaybeComplete( FCB, STATUS_NO_MEMORY, Irp, 0 );
 
     FCB->ContextSize = IrpSp->Parameters.DeviceIoControl.InputBufferLength;
 
     RtlCopyMemory( FCB->Context,
-                  Context,
-                  FCB->ContextSize );
+                   Context,
+                   FCB->ContextSize );
 
     return UnlockAndMaybeComplete( FCB, STATUS_SUCCESS, Irp, 0 );
 }