Corrected a memory leak in the read cleanup code

svn path=/trunk/; revision=116
This commit is contained in:
David Welch 1998-12-08 19:44:04 +00:00
parent 4bc75819a3
commit 6eaf6180fd
7 changed files with 31 additions and 12 deletions

View file

@ -37,6 +37,7 @@ VOID IoReadWriteCompletion(PDEVICE_OBJECT DeviceObject,
DPRINT("Copying buffered io back to user\n");
memcpy(Irp->UserBuffer,Irp->AssociatedIrp.SystemBuffer,
IoStack->Parameters.Read.Length);
ExFreePool(Irp->AssociatedIrp.SystemBuffer);
}
if (DeviceObject->Flags & DO_DIRECT_IO)
{

View file

@ -17,7 +17,7 @@
#include <internal/string.h>
#include <wstring.h>
//#define NDEBUG
#define NDEBUG
#include <internal/debug.h>
/* FUNCTIONS *************************************************************/

View file

@ -25,6 +25,7 @@
static LIST_ENTRY DpcQueueHead={NULL,NULL};
static KSPIN_LOCK DpcQueueLock={0,};
ULONG DpcQueueSize = 0;
/* FUNCTIONS ****************************************************************/
@ -68,6 +69,7 @@ void KeDrainDpcQueue(void)
current->Lock=FALSE;
KeRaiseIrql(HIGH_LEVEL,&oldlvl);
current_entry = RemoveHeadList(&DpcQueueHead);
DpcQueueSize--;
KeLowerIrql(oldlvl);
current = CONTAINING_RECORD(&current_entry,KDPC,DpcListEntry);
}
@ -88,6 +90,7 @@ BOOLEAN KeRemoveQueueDpc(PKDPC Dpc)
return(FALSE);
}
RemoveEntryList(&Dpc->DpcListEntry);
DpcQueueSize--;
Dpc->Lock=0;
return(TRUE);
}
@ -117,6 +120,7 @@ BOOLEAN KeInsertQueueDpc(PKDPC dpc, PVOID SystemArgument1,
}
KeAcquireSpinLockAtDpcLevel(&DpcQueueLock);
InsertHeadList(&DpcQueueHead,&dpc->DpcListEntry);
DpcQueueSize++;
KeReleaseSpinLockFromDpcLevel(&DpcQueueLock);
dpc->Lock=(PULONG)1;
DPRINT("DpcQueueHead.Flink %x\n",DpcQueueHead.Flink);

View file

@ -17,6 +17,7 @@
#include <limits.h>
#include <ddk/ntddk.h>
#include <string.h>
#define NDEBUG
#include <internal/debug.h>
@ -413,6 +414,8 @@ static void HandleExpiredTimer(PKTIMER current)
{
if (current->dpc!=NULL)
{
DPRINT("current->dpc->DeferredRoutine %x\n",
current->dpc->DeferredRoutine);
current->dpc->DeferredRoutine(current->dpc,
current->dpc->DeferredContext,
current->dpc->SystemArgument1,
@ -457,13 +460,15 @@ void KeExpireTimers(void)
KeReleaseSpinLock(&timer_list_lock,oldlvl);
}
extern unsigned int nr_used_blocks;
VOID KiTimerInterrupt(VOID)
/*
* FUNCTION: Handles a timer interrupt
*/
{
char str[16];
char* vidmem=(char *)physical_to_linear(0xb8000 + 160 - 16);
char str[36];
char* vidmem=(char *)physical_to_linear(0xb8000 + 160 - 36);
int i;
/*
@ -476,8 +481,8 @@ VOID KiTimerInterrupt(VOID)
* Display the tick count in the top left of the screen as a debugging
* aid
*/
sprintf(str,"%.8u",ticks);
for (i=0;i<8;i++)
sprintf(str,"%.8u %.8u",nr_used_blocks,ticks);
for (i=0;i<17;i++)
{
*vidmem=str[i];
vidmem++;

View file

@ -58,7 +58,7 @@ static unsigned int kernel_pool_base = 0;
static block_hdr* free_list_head = NULL;
static block_hdr* used_list_head = NULL;
static unsigned int nr_free_blocks = 0;
static unsigned int nr_used_blocks = 0;
unsigned int nr_used_blocks = 0;
#define ALLOC_MAP_SIZE (NONPAGED_POOL_SIZE / PAGESIZE)

View file

@ -310,7 +310,7 @@ ZwAllocateVirtualMemory(
ULONG Type;
NTSTATUS Status;
DbgPrint("ZwAllocateVirtualMemory(ProcessHandle %x, *BaseAddress %x, "
DPRINT("ZwAllocateVirtualMemory(ProcessHandle %x, *BaseAddress %x, "
"ZeroBits %d, RegionSize %d, AllocationType %x, Protect %x)\n",
ProcessHandle,*BaseAddress,ZeroBits,*RegionSize,AllocationType,
Protect);
@ -323,7 +323,7 @@ ZwAllocateVirtualMemory(
NULL);
if (Status != STATUS_SUCCESS)
{
DbgPrint("ZwAllocateVirtualMemory() = %x\n",Status);
DPRINT("ZwAllocateVirtualMemory() = %x\n",Status);
return(Status);
}
@ -347,7 +347,7 @@ ZwAllocateVirtualMemory(
{
MemoryArea->Type = Type;
MemoryArea->Attributes =Protect;
DbgPrint("*BaseAddress %x\n",*BaseAddress);
DPRINT("*BaseAddress %x\n",*BaseAddress);
return(STATUS_SUCCESS);
}
@ -357,7 +357,7 @@ ZwAllocateVirtualMemory(
*RegionSize,
Type,
Protect);
DbgPrint("*BaseAddress %x\n",*BaseAddress);
DPRINT("*BaseAddress %x\n",*BaseAddress);
return(STATUS_SUCCESS);
}
}
@ -375,11 +375,11 @@ ZwAllocateVirtualMemory(
if (Status != STATUS_SUCCESS)
{
DbgPrint("ZwAllocateVirtualMemory() = %x\n",Status);
DPRINT("ZwAllocateVirtualMemory() = %x\n",Status);
return(Status);
}
DbgPrint("*BaseAddress %x\n",*BaseAddress);
DPRINT("*BaseAddress %x\n",*BaseAddress);
return(STATUS_SUCCESS);
}

View file

@ -17,14 +17,23 @@
/* GLOBALS *******************************************************************/
HANDLE IdleThreadHandle = NULL;
extern ULONG DpcQueueSize;
/* FUNCTIONS *****************************************************************/
static VOID PsIdleThreadMain(PVOID Context)
{
KIRQL oldlvl;
for(;;)
{
// DbgPrint("Idling.... ");
if (DpcQueueSize > 0)
{
KeRaiseIrql(DISPATCH_LEVEL,&oldlvl);
KeDrainDpcQueue();
KeLowerIrql(oldlvl);
}
ZwYieldExecution();
}
}