add some asserts
[reactos.git] / reactos / ntoskrnl / io / mdl.c
index 71bfb36..b4b423f 100644 (file)
@@ -1,12 +1,11 @@
-/* $Id: mdl.c,v 1.17 2004/08/15 16:39:03 chorns Exp $
+/* $Id$
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
  * FILE:            ntoskrnl/io/mdl.c
  * PURPOSE:         Io manager mdl functions
- * PROGRAMMER:      David Welch (welch@mcmail.com)
- * UPDATE HISTORY:
- *                  Created 22/05/98
+ *
+ * PROGRAMMERS:     David Welch (welch@mcmail.com)
  */
 
 /* INCLUDES *****************************************************************/
@@ -33,7 +32,7 @@ IoAllocateMdl(PVOID VirtualAddress,
                   PIRP Irp)
 {
    PMDL Mdl;
-   
+
    if (ChargeQuota)
      {
 //     Mdl = ExAllocatePoolWithQuota(NonPagedPool,
@@ -49,27 +48,27 @@ IoAllocateMdl(PVOID VirtualAddress,
                                    TAG_MDL);
      }
    MmInitializeMdl(Mdl, (char*)VirtualAddress, Length);
-   
+
    if (Irp)
    {
       if (SecondaryBuffer)
       {
-         assert(Irp->MdlAddress);
-         
+         ASSERT(Irp->MdlAddress);
+
          /* FIXME: add to end of list maybe?? */
          Mdl->Next = Irp->MdlAddress->Next;
          Irp->MdlAddress->Next = Mdl;
       }
       else
       {
-         /* 
+         /*
           * What if there's allready an mdl at Irp->MdlAddress?
           * Is that bad and should we do something about it?
           */
          Irp->MdlAddress = Mdl;
       }
    }
-   
+
    return(Mdl);
 }
 
@@ -102,7 +101,7 @@ IoBuildPartialMdl(PMDL SourceMdl,
    TargetMdl->ByteCount = Length;
    TargetMdl->Process = SourceMdl->Process;
    Delta = (ULONG_PTR)VirtualAddress - ((ULONG_PTR)SourceMdl->StartVa + SourceMdl->ByteOffset);
-   TargetMdl->MappedSystemVa = SourceMdl->MappedSystemVa + Delta;
+   TargetMdl->MappedSystemVa = (char*)SourceMdl->MappedSystemVa + Delta;
 
    TargetMdl->MdlFlags = SourceMdl->MdlFlags & (MDL_IO_PAGE_READ|MDL_SOURCE_IS_NONPAGED_POOL|MDL_MAPPED_TO_SYSTEM_VA);
    TargetMdl->MdlFlags |= MDL_PARTIAL;
@@ -123,13 +122,16 @@ IoBuildPartialMdl(PMDL SourceMdl,
  */
 VOID STDCALL
 IoFreeMdl(PMDL Mdl)
-{   
-   /* 
+{
+   /*
     * This unmaps partial mdl's from kernel space but also asserts that non-partial
     * mdl's isn't still mapped into kernel space.
     */
+   ASSERT(Mdl);
+   ASSERT_IRQL(DISPATCH_LEVEL);
+
    MmPrepareMdlForReuse(Mdl);
-   
+
    ExFreePool(Mdl);
 }