ReactOS  0.4.14-dev-297-g23e575c
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 }
static HANDLE ProcessHeapHandle
Definition: utility.c:13
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
static UINT CurrentAllocations
Definition: utility.c:14

◆ 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 }
static HANDLE ProcessHeapHandle
Definition: utility.c:13
#define SND_ASSERT(condition)
static UINT CurrentAllocations
Definition: utility.c:14
#define HeapFree(x, y, z)
Definition: compat.h:394

◆ GetDigitCount()

UINT GetDigitCount ( IN UINT  Number)

Definition at line 68 of file utility.c.

70 {
71  UINT Value = Number;
72  ULONG Digits = 1;
73 
74  while ( Value > 9 )
75  {
76  Value /= 10;
77  ++ Digits;
78  }
79 
80  return Digits;
81 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
_In_opt_ PENTER_STATE_SYSTEM_HANDLER _In_opt_ PVOID _In_ LONG _In_opt_ LONG volatile * Number
Definition: ntpoapi.h:204
unsigned int UINT
Definition: ndis.h:50
unsigned int ULONG
Definition: retypes.h:1

Referenced by DetectNt4SoundDevices(), and OpenSoundDeviceRegKey().

◆ GetMemoryAllocationCount()

UINT GetMemoryAllocationCount ( )

Definition at line 58 of file utility.c.

59 {
60  return CurrentAllocations;
61 }
static UINT CurrentAllocations
Definition: utility.c:14

◆ TranslateInternalMmResult()

MMRESULT TranslateInternalMmResult ( IN MMRESULT  Result)

Definition at line 132 of file utility.c.

134 {
135  switch ( Result )
136  {
137  case MMSYSERR_INVALPARAM :
138  case MMSYSERR_INVALFLAG :
139  {
140  return MMSYSERR_ERROR;
141  }
142  }
143 
144  return Result;
145 }
_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:426
#define MMSYSERR_ERROR
Definition: mmsystem.h:97
#define MMSYSERR_INVALFLAG
Definition: mmsystem.h:106
#define MMSYSERR_INVALPARAM
Definition: mmsystem.h:107

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(), 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 
99  case ERROR_NOT_SUPPORTED :
101  return MMSYSERR_NOTSUPPORTED;
102 
104  return MMSYSERR_NOMEM;
105 
106  case ERROR_ACCESS_DENIED :
107  return MMSYSERR_BADDEVICEID;
108 
110  return MMSYSERR_INVALPARAM;
111 
113  return MMSYSERR_INVALPARAM;
114 
115 
116  default :
117  return MMSYSERR_ERROR;
118  }
119 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define ERROR_IO_PENDING
Definition: dderror.h:15
#define NO_ERROR
Definition: dderror.h:5
#define ERROR_BUSY
Definition: dderror.h:12
#define MMSYSERR_NOMEM
Definition: mmsystem.h:103
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define MMSYSERR_ERROR
Definition: mmsystem.h:97
#define MMSYSERR_ALLOCATED
Definition: mmsystem.h:100
#define MMSYSERR_NOTSUPPORTED
Definition: mmsystem.h:104
#define MMSYSERR_BADDEVICEID
Definition: mmsystem.h:98
#define MMSYSERR_INVALPARAM
Definition: mmsystem.h:107
#define ERROR_NOT_SUPPORTED
Definition: compat.h:90
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

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().