Home | Info | Community | Development | myReactOS | Contact Us
Definition at line 929 of file misc.c.
{ PtrExt2FileLockInfo PtrByteLocks = NULL; BOOLEAN AllocatedFromZone = TRUE; KIRQL CurrentIrql; // first, try to allocate out of the zone KeAcquireSpinLock(&(Ext2GlobalData.ZoneAllocationSpinLock), &CurrentIrql); if (!ExIsFullZone(&(Ext2GlobalData.ByteLockZoneHeader))) { // we have enough memory PtrByteLocks = (PtrExt2FileLockInfo)ExAllocateFromZone(&(Ext2GlobalData.ByteLockZoneHeader)); // release the spinlock KeReleaseSpinLock(&(Ext2GlobalData.ZoneAllocationSpinLock), CurrentIrql); } else { // release the spinlock KeReleaseSpinLock(&(Ext2GlobalData.ZoneAllocationSpinLock), CurrentIrql); // if we failed to obtain from the zone, get it directly from the VMM PtrByteLocks = (PtrExt2FileLockInfo)Ext2AllocatePool(NonPagedPool, Ext2QuadAlign(sizeof(Ext2FileLockInfo)) ); AllocatedFromZone = FALSE; } // if we could not obtain the required memory, bug-check. // Do NOT do this in your commercial driver, instead handle the error gracefully ... if (!PtrByteLocks) { Ext2Panic(STATUS_INSUFFICIENT_RESOURCES, Ext2QuadAlign(sizeof(Ext2FileLockInfo)), 0); } // zero out the allocated memory block RtlZeroMemory(PtrByteLocks, Ext2QuadAlign(sizeof(PtrExt2FileLockInfo))); if (!AllocatedFromZone) { Ext2SetFlag(PtrByteLocks->FileLockFlags, EXT2_BYTE_LOCK_NOT_FROM_ZONE); } return(PtrByteLocks); }