Author: janderwald
Date: Sat Jun 19 07:26:20 2010
New Revision: 47804
URL:
http://svn.reactos.org/svn/reactos?rev=47804&view=rev
Log:
[SYSAUDIO]
- Perform all allocations / frees in dedicated alloc / free function
Modified:
trunk/reactos/drivers/wdm/audio/sysaudio/control.c
trunk/reactos/drivers/wdm/audio/sysaudio/deviface.c
trunk/reactos/drivers/wdm/audio/sysaudio/dispatcher.c
trunk/reactos/drivers/wdm/audio/sysaudio/main.c
trunk/reactos/drivers/wdm/audio/sysaudio/pin.c
trunk/reactos/drivers/wdm/audio/sysaudio/sysaudio.h
Modified: trunk/reactos/drivers/wdm/audio/sysaudio/control.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/sysaudio…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/sysaudio/control.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/sysaudio/control.c [iso-8859-1] Sat Jun 19 07:26:20
2010
@@ -145,7 +145,7 @@
ULONG Index;
Length = sizeof(KSP_PIN) + sizeof(KSMULTIPLE_ITEM) +
ClientFormat->DataFormat.FormatSize;
- PinRequest = ExAllocatePool(NonPagedPool, Length);
+ PinRequest = AllocateItem(NonPagedPool, Length);
if (!PinRequest)
return STATUS_UNSUCCESSFUL;
@@ -166,7 +166,7 @@
if (NT_SUCCESS(Status))
{
- ExFreePool(PinRequest);
+ FreeItem(PinRequest);
return Status;
}
@@ -181,10 +181,10 @@
return Status;
}
- MultipleItem = ExAllocatePool(NonPagedPool, BytesReturned);
+ MultipleItem = AllocateItem(NonPagedPool, BytesReturned);
if (!MultipleItem)
{
- ExFreePool(PinRequest);
+ FreeItem(PinRequest);
return STATUS_NO_MEMORY;
}
@@ -192,8 +192,8 @@
if (!NT_SUCCESS(Status))
{
DPRINT("Property Request KSPROPERTY_PIN_DATARANGES failed with %x\n",
Status);
- ExFreePool(MultipleItem);
- ExFreePool(PinRequest);
+ FreeItem(MultipleItem);
+ FreeItem(PinRequest);
return STATUS_UNSUCCESSFUL;
}
@@ -253,8 +253,8 @@
#endif
- ExFreePool(MultipleItem);
- ExFreePool(PinRequest);
+ FreeItem(MultipleItem);
+ FreeItem(PinRequest);
if (bFound)
return STATUS_SUCCESS;
Modified: trunk/reactos/drivers/wdm/audio/sysaudio/deviface.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/sysaudio…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/sysaudio/deviface.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/sysaudio/deviface.c [iso-8859-1] Sat Jun 19 07:26:20
2010
@@ -70,7 +70,7 @@
PKSAUDIO_DEVICE_ENTRY DeviceEntry = NULL;
/* a new device has arrived */
- DeviceEntry = ExAllocatePool(NonPagedPool, sizeof(KSAUDIO_DEVICE_ENTRY));
+ DeviceEntry = AllocateItem(NonPagedPool, sizeof(KSAUDIO_DEVICE_ENTRY));
if (!DeviceEntry)
{
/* no memory */
@@ -84,7 +84,7 @@
DeviceEntry->DeviceName.Length = 0;
DeviceEntry->DeviceName.MaximumLength = DeviceName->MaximumLength + 10 *
sizeof(WCHAR);
- DeviceEntry->DeviceName.Buffer = ExAllocatePool(NonPagedPool,
DeviceEntry->DeviceName.MaximumLength);
+ DeviceEntry->DeviceName.Buffer = AllocateItem(NonPagedPool,
DeviceEntry->DeviceName.MaximumLength);
if (!DeviceEntry->DeviceName.Buffer)
{
@@ -115,9 +115,9 @@
if (DeviceEntry)
{
if (DeviceEntry->DeviceName.Buffer)
- ExFreePool(DeviceEntry->DeviceName.Buffer);
-
- ExFreePool(DeviceEntry);
+ FreeItem(DeviceEntry->DeviceName.Buffer);
+
+ FreeItem(DeviceEntry);
}
return Status;
Modified: trunk/reactos/drivers/wdm/audio/sysaudio/dispatcher.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/sysaudio…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/sysaudio/dispatcher.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/sysaudio/dispatcher.c [iso-8859-1] Sat Jun 19 07:26:20
2010
@@ -70,7 +70,7 @@
DPRINT("DispatchCreateSysAudio entered\n");
/* allocate create item */
- CreateItem = ExAllocatePool(NonPagedPool, sizeof(KSOBJECT_CREATE_ITEM));
+ CreateItem = AllocateItem(NonPagedPool, sizeof(KSOBJECT_CREATE_ITEM));
if (!CreateItem)
{
Irp->IoStatus.Information = 0;
@@ -105,7 +105,7 @@
PKSOBJECT_CREATE_ITEM CreateItem;
/* allocate create item */
- CreateItem = ExAllocatePool(NonPagedPool, sizeof(KSOBJECT_CREATE_ITEM));
+ CreateItem = AllocateItem(NonPagedPool, sizeof(KSOBJECT_CREATE_ITEM));
if (!CreateItem)
return STATUS_INSUFFICIENT_RESOURCES;
Modified: trunk/reactos/drivers/wdm/audio/sysaudio/main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/sysaudio…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/sysaudio/main.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/sysaudio/main.c [iso-8859-1] Sat Jun 19 07:26:20 2010
@@ -18,6 +18,25 @@
const GUID KSCATEGORY_PREFERRED_WAVEIN_DEVICE = {0xD6C50671L, 0x72C1, 0x11D2, {0x97,
0x55, 0x00, 0x00, 0xF8, 0x00, 0x47, 0x88}};
const GUID KSCATEGORY_PREFERRED_MIDIOUT_DEVICE = {0xD6C50674L, 0x72C1, 0x11D2, {0x97,
0x55, 0x00, 0x00, 0xF8, 0x00, 0x47, 0x88}};
+PVOID
+AllocateItem(
+ IN POOL_TYPE PoolType,
+ IN SIZE_T NumberOfBytes)
+{
+ PVOID Item = ExAllocatePool(PoolType, NumberOfBytes);
+ if (!Item)
+ return Item;
+
+ RtlZeroMemory(Item, NumberOfBytes);
+ return Item;
+}
+
+VOID
+FreeItem(
+ IN PVOID Item)
+{
+ ExFreePool(Item);
+}
VOID
@@ -58,7 +77,7 @@
RtlFreeUnicodeString(&DeviceEntry->DeviceName);
/* free audio device entry */
- ExFreePool(DeviceEntry);
+ FreeItem(DeviceEntry);
}
Irp->IoStatus.Information = 0;
Modified: trunk/reactos/drivers/wdm/audio/sysaudio/pin.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/sysaudio…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/sysaudio/pin.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/sysaudio/pin.c [iso-8859-1] Sat Jun 19 07:26:20 2010
@@ -149,7 +149,7 @@
ZwClose(Context->hMixerPin);
}
- ExFreePool(Context);
+ FreeItem(Context);
Irp->IoStatus.Status = STATUS_SUCCESS;
Irp->IoStatus.Information = 0;
@@ -315,7 +315,7 @@
/* the audio irp pin didnt accept the input format
* let's compute a compatible format
*/
- MixerPinConnect = ExAllocatePool(NonPagedPool, sizeof(KSPIN_CONNECT) +
sizeof(KSDATAFORMAT_WAVEFORMATEX));
+ MixerPinConnect = AllocateItem(NonPagedPool, sizeof(KSPIN_CONNECT) +
sizeof(KSDATAFORMAT_WAVEFORMATEX));
if (!MixerPinConnect)
{
/* not enough memory */
@@ -335,7 +335,7 @@
if (!NT_SUCCESS(Status))
{
DPRINT1("ComputeCompatibleFormat failed with %x\n", Status);
- ExFreePool(MixerPinConnect);
+ FreeItem(MixerPinConnect);
return Status;
}
@@ -348,7 +348,7 @@
DPRINT1(" InputFormat: SampleRate %u Bits %u Channels %u\n",
InputFormat->WaveFormatEx.nSamplesPerSec, InputFormat->WaveFormatEx.wBitsPerSample,
InputFormat->WaveFormatEx.nChannels);
DPRINT1("OutputFormat: SampleRate %u Bits %u Channels %u\n",
OutputFormat->WaveFormatEx.nSamplesPerSec,
OutputFormat->WaveFormatEx.wBitsPerSample, OutputFormat->WaveFormatEx.nChannels);
- ExFreePool(MixerPinConnect);
+ FreeItem(MixerPinConnect);
return Status;
}
}
@@ -378,7 +378,7 @@
if (!NT_SUCCESS(Status))
{
DPRINT1("Failed to create Mixer Pin with %x\n", Status);
- ExFreePool(MixerPinConnect);
+ FreeItem(MixerPinConnect);
}
}
/* done */
@@ -408,7 +408,7 @@
ParametersLength = IoStack->FileObject->FileName.MaximumLength - ObjectLength;
/* allocate buffer */
- Buffer = ExAllocatePool(NonPagedPool, ParametersLength);
+ Buffer = AllocateItem(NonPagedPool, ParametersLength);
if (!Buffer)
return STATUS_INSUFFICIENT_RESOURCES;
@@ -471,7 +471,7 @@
/* allocate dispatch context */
- DispatchContext = ExAllocatePool(NonPagedPool, sizeof(DISPATCH_CONTEXT));
+ DispatchContext = AllocateItem(NonPagedPool, sizeof(DISPATCH_CONTEXT));
if (!DispatchContext)
{
/* failed */
@@ -488,7 +488,7 @@
if (!NT_SUCCESS(Status))
{
/* failed */
- ExFreePool(DispatchContext);
+ FreeItem(DispatchContext);
Irp->IoStatus.Status = Status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return Status;
@@ -500,7 +500,7 @@
{
/* failed */
KsFreeObjectHeader(DispatchContext->ObjectHeader);
- ExFreePool(DispatchContext);
+ FreeItem(DispatchContext);
}
else
{
Modified: trunk/reactos/drivers/wdm/audio/sysaudio/sysaudio.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/sysaudio…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/sysaudio/sysaudio.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/sysaudio/sysaudio.h [iso-8859-1] Sat Jun 19 07:26:20
2010
@@ -116,3 +116,13 @@
IN ULONG PinId,
IN PKSDATAFORMAT_WAVEFORMATEX ClientFormat,
OUT PKSDATAFORMAT_WAVEFORMATEX MixerFormat);
+
+PVOID
+AllocateItem(
+ IN POOL_TYPE PoolType,
+ IN SIZE_T NumberOfBytes);
+
+VOID
+FreeItem(
+ IN PVOID Item);
+