Author: janderwald
Date: Fri Jun 11 12:28:10 2010
New Revision: 47754
URL:
http://svn.reactos.org/svn/reactos?rev=47754&view=rev
Log:
[WDMAUD_KERNEL]
- Perform all allocations / frees in dedicated alloc / free function
Modified:
trunk/reactos/drivers/wdm/audio/legacy/wdmaud/control.c
trunk/reactos/drivers/wdm/audio/legacy/wdmaud/deviface.c
trunk/reactos/drivers/wdm/audio/legacy/wdmaud/entry.c
trunk/reactos/drivers/wdm/audio/legacy/wdmaud/mmixer.c
trunk/reactos/drivers/wdm/audio/legacy/wdmaud/sup.c
trunk/reactos/drivers/wdm/audio/legacy/wdmaud/wdmaud.h
Modified: trunk/reactos/drivers/wdm/audio/legacy/wdmaud/control.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/legacy/w…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/legacy/wdmaud/control.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/legacy/wdmaud/control.c [iso-8859-1] Fri Jun 11
12:28:10 2010
@@ -251,7 +251,7 @@
RtlMoveMemory(DeviceInfo->u.Interface.DeviceInterfaceString, Device,
Length);
}
- ExFreePool(Device);
+ FreeItem(Device);
return SetIrpIoStatus(Irp, STATUS_SUCCESS, sizeof(WDMAUD_DEVICE_INFO));
}
else if (DeviceInfo->DeviceType == MIXER_DEVICE_TYPE)
Modified: trunk/reactos/drivers/wdm/audio/legacy/wdmaud/deviface.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/legacy/w…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/legacy/wdmaud/deviface.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/legacy/wdmaud/deviface.c [iso-8859-1] Fri Jun 11
12:28:10 2010
@@ -65,7 +65,7 @@
while(*SymbolicLinkList)
{
Length = wcslen(SymbolicLinkList) + 1;
- Entry = (SYSAUDIO_ENTRY*)ExAllocatePool(NonPagedPool, sizeof(SYSAUDIO_ENTRY) +
Length * sizeof(WCHAR));
+ Entry = (SYSAUDIO_ENTRY*)AllocateItem(NonPagedPool, sizeof(SYSAUDIO_ENTRY) +
Length * sizeof(WCHAR));
if (!Entry)
{
return STATUS_INSUFFICIENT_RESOURCES;
@@ -108,7 +108,7 @@
if (NT_SUCCESS(Status))
{
WdmAudOpenSysAudioDeviceInterfaces(DeviceExtension, SymbolicLinkList);
- ExFreePool(SymbolicLinkList);
+ FreeItem(SymbolicLinkList);
}
@@ -123,7 +123,7 @@
else
{
Length = wcslen(DeviceName.Buffer) + 1;
- Entry = (SYSAUDIO_ENTRY*)ExAllocatePool(NonPagedPool, sizeof(SYSAUDIO_ENTRY)
+ Length * sizeof(WCHAR));
+ Entry = (SYSAUDIO_ENTRY*)AllocateItem(NonPagedPool, sizeof(SYSAUDIO_ENTRY) +
Length * sizeof(WCHAR));
if (!Entry)
{
return STATUS_INSUFFICIENT_RESOURCES;
@@ -218,7 +218,7 @@
ASSERT(!IsListEmpty(&DeviceExtension->SysAudioDeviceList));
/* allocate client context struct */
- Client = ExAllocatePool(NonPagedPool, sizeof(WDMAUD_CLIENT));
+ Client = AllocateItem(NonPagedPool, sizeof(WDMAUD_CLIENT));
/* check for allocation failure */
if (!Client)
Modified: trunk/reactos/drivers/wdm/audio/legacy/wdmaud/entry.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/legacy/w…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/legacy/wdmaud/entry.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/legacy/wdmaud/entry.c [iso-8859-1] Fri Jun 11 12:28:10
2010
@@ -240,10 +240,10 @@
/* free pin array */
if (pClient->hPins)
- ExFreePool(pClient->hPins);
+ FreeItem(pClient->hPins);
/* free client context struct */
- ExFreePool(pClient);
+ FreeItem(pClient);
/* clear old client pointer */
IoStack->FileObject->FsContext = NULL;
Modified: trunk/reactos/drivers/wdm/audio/legacy/wdmaud/mmixer.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/legacy/w…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/legacy/wdmaud/mmixer.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/legacy/wdmaud/mmixer.c [iso-8859-1] Fri Jun 11
12:28:10 2010
@@ -65,7 +65,7 @@
return MM_STATUS_UNSUCCESSFUL;
/* allocate a buffer for key data */
- PartialInformation = ExAllocatePool(NonPagedPool, Length);
+ PartialInformation = AllocateItem(NonPagedPool, Length);
if (!PartialInformation)
return MM_STATUS_NO_MEMORY;
@@ -77,7 +77,7 @@
/* check for success */
if (!NT_SUCCESS(Status))
{
- ExFreePool(PartialInformation);
+ FreeItem(PartialInformation);
return MM_STATUS_UNSUCCESSFUL;
}
@@ -93,11 +93,11 @@
*ResultLength = PartialInformation->DataLength;
}
- *ResultBuffer = ExAllocatePool(NonPagedPool, PartialInformation->DataLength);
+ *ResultBuffer = AllocateItem(NonPagedPool, PartialInformation->DataLength);
if (!*ResultBuffer)
{
/* not enough memory */
- ExFreePool(PartialInformation);
+ FreeItem(PartialInformation);
return MM_STATUS_NO_MEMORY;
}
@@ -105,7 +105,7 @@
RtlMoveMemory(*ResultBuffer, PartialInformation->Data,
PartialInformation->DataLength);
/* free key info */
- ExFreePool(PartialInformation);
+ FreeItem(PartialInformation);
return MM_STATUS_SUCCESS;
}
@@ -149,12 +149,7 @@
PVOID Alloc(ULONG NumBytes)
{
- PVOID Mem = ExAllocatePool(NonPagedPool, NumBytes);
- if (!Mem)
- return Mem;
-
- RtlZeroMemory(Mem, NumBytes);
- return Mem;
+ return AllocateItem(NonPagedPool, NumBytes);
}
MIXER_STATUS
@@ -169,7 +164,7 @@
VOID
Free(PVOID Block)
{
- ExFreePool(Block);
+ FreeItem(Block);
}
VOID
@@ -277,7 +272,7 @@
{
/* failed to open key */
DPRINT("IoOpenDeviceInterfaceRegistryKey failed with %lx\n", Status);
- ExFreePool(*DeviceName);
+ FreeItem(*DeviceName);
return MM_STATUS_UNSUCCESSFUL;
}
#endif
@@ -297,14 +292,14 @@
AllocEventData(
IN ULONG ExtraSize)
{
- PKSEVENTDATA Data = (PKSEVENTDATA)ExAllocatePool(NonPagedPool, sizeof(KSEVENTDATA) +
ExtraSize);
+ PKSEVENTDATA Data = (PKSEVENTDATA)AllocateItem(NonPagedPool, sizeof(KSEVENTDATA) +
ExtraSize);
if (!Data)
return NULL;
- Data->EventObject.Event = ExAllocatePool(NonPagedPool, sizeof(KEVENT));
+ Data->EventObject.Event = AllocateItem(NonPagedPool, sizeof(KEVENT));
if (!Data->EventHandle.Event)
{
- ExFreePool(Data);
+ FreeItem(Data);
return NULL;
}
@@ -319,8 +314,8 @@
{
PKSEVENTDATA Data = (PKSEVENTDATA)EventData;
- ExFreePool(Data->EventHandle.Event);
- ExFreePool(Data);
+ FreeItem(Data->EventHandle.Event);
+ FreeItem(Data);
}
NTSTATUS
@@ -391,14 +386,14 @@
}
- Handles = ExAllocatePool(NonPagedPool, sizeof(WDMAUD_HANDLE) *
(ClientInfo->NumPins+1));
+ Handles = AllocateItem(NonPagedPool, sizeof(WDMAUD_HANDLE) *
(ClientInfo->NumPins+1));
if (Handles)
{
if (ClientInfo->NumPins)
{
RtlMoveMemory(Handles, ClientInfo->hPins, sizeof(WDMAUD_HANDLE) *
ClientInfo->NumPins);
- ExFreePool(ClientInfo->hPins);
+ FreeItem(ClientInfo->hPins);
}
ClientInfo->hPins = Handles;
Modified: trunk/reactos/drivers/wdm/audio/legacy/wdmaud/sup.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/legacy/w…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/legacy/wdmaud/sup.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/legacy/wdmaud/sup.c [iso-8859-1] Fri Jun 11 12:28:10
2010
@@ -8,6 +8,28 @@
*/
#include "wdmaud.h"
+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);
+}
+
+
+
ULONG
GetSysAudioDeviceCount(
IN PDEVICE_OBJECT DeviceObject)
@@ -92,7 +114,7 @@
return STATUS_SUCCESS;
}
- Handles = ExAllocatePool(NonPagedPool, sizeof(WDMAUD_HANDLE) *
(ClientInfo->NumPins+1));
+ Handles = AllocateItem(NonPagedPool, sizeof(WDMAUD_HANDLE) *
(ClientInfo->NumPins+1));
if (!Handles)
return STATUS_INSUFFICIENT_RESOURCES;
@@ -100,7 +122,7 @@
if (ClientInfo->NumPins)
{
RtlMoveMemory(Handles, ClientInfo->hPins, sizeof(WDMAUD_HANDLE) *
ClientInfo->NumPins);
- ExFreePool(ClientInfo->hPins);
+ FreeItem(ClientInfo->hPins);
}
ClientInfo->hPins = Handles;
@@ -130,7 +152,7 @@
return NULL;
/* allocate a buffer for key data */
- PartialInformation = ExAllocatePool(NonPagedPool, Length);
+ PartialInformation = AllocateItem(NonPagedPool, Length);
if (!PartialInformation)
return NULL;
@@ -142,14 +164,14 @@
/* check for success */
if (!NT_SUCCESS(Status))
{
- ExFreePool(PartialInformation);
+ FreeItem(PartialInformation);
return NULL;
}
if (PartialInformation->Type != REG_SZ)
{
/* invalid key type */
- ExFreePool(PartialInformation);
+ FreeItem(PartialInformation);
return NULL;
}
@@ -189,12 +211,12 @@
if (_wcsnicmp((LPWSTR)PartialInformation->Data, &PnpName[4], Length))
{
- ExFreePool(PartialInformation);
+ FreeItem(PartialInformation);
return STATUS_NO_MATCH;
}
/* free buffer */
- ExFreePool(PartialInformation);
+ FreeItem(PartialInformation);
/* read DriverDescName value */
PartialInformation = ReadKeyValue(hSubKey, &DriverDescName);
@@ -213,7 +235,7 @@
ProductName[ProductNameSize-1] = L'\0';
/* free buffer */
- ExFreePool(PartialInformation);
+ FreeItem(PartialInformation);
return STATUS_SUCCESS;
}
@@ -265,7 +287,7 @@
}
/* allocate key information struct */
- KeyInformation = ExAllocatePool(NonPagedPool, Length);
+ KeyInformation = AllocateItem(NonPagedPool, Length);
if (!KeyInformation)
{
/* no memory */
@@ -279,7 +301,7 @@
if (!NT_SUCCESS(Status))
{
DPRINT1("ZwQueryKey failed with %x\n", Status);
- ExFreePool(KeyInformation);
+ FreeItem(KeyInformation);
ZwClose(hKey);
return Status;
}
@@ -314,7 +336,7 @@
}
/* free buffer */
- ExFreePool(KeyInformation);
+ FreeItem(KeyInformation);
/* close key */
ZwClose(hKey);
@@ -354,7 +376,7 @@
return STATUS_UNSUCCESSFUL;
/* allocate buffer for the device */
- *Device = ExAllocatePool(NonPagedPool, BytesReturned);
+ *Device = AllocateItem(NonPagedPool, BytesReturned);
if (!Device)
return STATUS_INSUFFICIENT_RESOURCES;
@@ -364,7 +386,7 @@
if (!NT_SUCCESS(Status))
{
/* failed */
- ExFreePool(*Device);
+ FreeItem(*Device);
return Status;
}
Modified: trunk/reactos/drivers/wdm/audio/legacy/wdmaud/wdmaud.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/legacy/w…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/legacy/wdmaud/wdmaud.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/legacy/wdmaud/wdmaud.h [iso-8859-1] Fri Jun 11
12:28:10 2010
@@ -276,3 +276,14 @@
ULONG
GetSysAudioDeviceCount(
IN PDEVICE_OBJECT DeviceObject);
+
+
+PVOID
+AllocateItem(
+ IN POOL_TYPE PoolType,
+ IN SIZE_T NumberOfBytes);
+
+VOID
+FreeItem(
+ IN PVOID Item);
+