ReactOS 0.4.15-dev-8102-g108db8f
utility.c File Reference
#include "precomp.h"
Include dependency graph for utility.c:

Go to the source code of this file.

Functions

PVOID AllocateMemory (IN UINT Size)
 
VOID FreeMemory (IN PVOID Pointer)
 
UINT GetMemoryAllocationCount ()
 
UINT GetDigitCount (IN UINT Number)
 
MMRESULT Win32ErrorToMmResult (IN UINT ErrorCode)
 
MMRESULT TranslateInternalMmResult (IN MMRESULT Result)
 

Variables

static HANDLE ProcessHeapHandle = NULL
 
static UINT CurrentAllocations = 0
 

Function Documentation

◆ AllocateMemory()

PVOID AllocateMemory ( IN UINT  Size)

Definition at line 20 of file utility.c.

22{
23 PVOID Pointer = NULL;
24
25 if ( ! ProcessHeapHandle )
27
29
30 if ( ! Pointer )
31 return NULL;
32
34
35 return Pointer;
36}
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
static HANDLE ProcessHeapHandle
Definition: utility.c:13
static UINT CurrentAllocations
Definition: utility.c:14
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533

◆ FreeMemory()

VOID FreeMemory ( IN PVOID  Pointer)

Definition at line 42 of file utility.c.

44{
46 SND_ASSERT( Pointer );
47
48 HeapFree(ProcessHeapHandle, 0, Pointer);
49
51}
#define HeapFree(x, y, z)
Definition: compat.h:735
#define SND_ASSERT(condition)

◆ GetDigitCount()

UINT GetDigitCount ( IN UINT  Number)

Definition at line 68 of file utility.c.

70{
72 ULONG Digits = 1;
73
74 while ( Value > 9 )
75 {
76 Value /= 10;
77 ++ Digits;
78 }
79
80 return Digits;
81}
unsigned int UINT
Definition: ndis.h:50
_In_opt_ PENTER_STATE_SYSTEM_HANDLER _In_opt_ PVOID _In_ LONG _In_opt_ LONG volatile * Number
Definition: ntpoapi.h:207
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

Referenced by DetectNt4SoundDevices(), and OpenSoundDeviceRegKey().

◆ GetMemoryAllocationCount()

UINT GetMemoryAllocationCount ( )

Definition at line 58 of file utility.c.

59{
60 return CurrentAllocations;
61}

Referenced by DriverProc().

◆ TranslateInternalMmResult()

MMRESULT TranslateInternalMmResult ( IN MMRESULT  Result)

Definition at line 132 of file utility.c.

134{
135 switch ( Result )
136 {
138 case MMSYSERR_INVALFLAG :
139 {
140 return MMSYSERR_ERROR;
141 }
142 }
143
144 return Result;
145}
#define MMSYSERR_INVALPARAM
Definition: mmsystem.h:107
#define MMSYSERR_ERROR
Definition: mmsystem.h:97
#define MMSYSERR_INVALFLAG
Definition: mmsystem.h:106
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

Referenced by CreateSoundDeviceInstance(), CreateSoundThread(), DestroySoundDeviceInstance(), GetNt4SoundDeviceCapabilities(), GetSoundDeviceCapabilities(), MmeCloseDevice(), MmeGetDeviceInterfaceString(), MmeGetLineInfo(), MmeGetPosition(), MmeOpenDevice(), MmeSetState(), OpenNt4KernelSoundDevice(), PopulateWdmDeviceList(), PrepareWaveHeader(), QueryNt4WaveDeviceFormatSupport(), QueryWaveDeviceFormatSupport(), SetNt4WaveDeviceFormat(), SetWaveDeviceFormat(), StopStreaming(), UnlistSoundDeviceInstance(), UnprepareWaveHeader(), WdmAudCloseSoundDeviceByLegacy(), WdmAudCloseSoundDeviceByMMixer(), WdmAudCommitWaveBufferByLegacy(), WdmAudCommitWaveBufferByMMixer(), WdmAudGetCapabilitiesByLegacy(), WdmAudGetDeviceInterfaceStringByLegacy(), WdmAudGetNumWdmDevsByLegacy(), WdmAudGetWavePositionByLegacy(), WdmAudGetWavePositionByMMixer(), WdmAudSetMixerDeviceFormatByLegacy(), WdmAudSetWaveDeviceFormatByLegacy(), WdmAudSetWaveDeviceFormatByMMixer(), WdmAudSetWaveStateByLegacy(), and WriteWaveHeader().

◆ Win32ErrorToMmResult()

MMRESULT Win32ErrorToMmResult ( IN UINT  ErrorCode)

Definition at line 87 of file utility.c.

89{
90 switch ( ErrorCode )
91 {
92 case NO_ERROR :
93 case ERROR_IO_PENDING :
94 return MMSYSERR_NOERROR;
95
96 case ERROR_BUSY :
97 return MMSYSERR_ALLOCATED;
98
102
104 return MMSYSERR_NOMEM;
105
108
110 return MMSYSERR_INVALPARAM;
111
113 return MMSYSERR_INVALPARAM;
114
115
116 default :
117 return MMSYSERR_ERROR;
118 }
119}
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define NO_ERROR
Definition: dderror.h:5
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define ERROR_BUSY
Definition: dderror.h:12
#define ERROR_IO_PENDING
Definition: dderror.h:15
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_NOT_SUPPORTED
Definition: compat.h:100
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
#define MMSYSERR_NOMEM
Definition: mmsystem.h:103
#define MMSYSERR_NOTSUPPORTED
Definition: mmsystem.h:104
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define MMSYSERR_ALLOCATED
Definition: mmsystem.h:100
#define MMSYSERR_BADDEVICEID
Definition: mmsystem.h:98
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436

Referenced by CreateSoundThread(), InitEntrypointMutexes(), OpenKernelSoundDeviceByName(), and SyncOverlappedDeviceIoControl().

Variable Documentation

◆ CurrentAllocations

UINT CurrentAllocations = 0
static

Definition at line 14 of file utility.c.

Referenced by AllocateMemory(), FreeMemory(), and GetMemoryAllocationCount().

◆ ProcessHeapHandle

HANDLE ProcessHeapHandle = NULL
static

Definition at line 13 of file utility.c.

Referenced by AllocateMemory(), and FreeMemory().