Commit 42a82726 authored by Gijs Vermeulen's avatar Gijs Vermeulen Committed by Alexandre Julliard

avifil32: Introduce ARRAY_SIZE macro.

parent 0aff523d
...@@ -156,7 +156,7 @@ static BOOL AVIFILE_GetFileHandlerByExtension(LPCWSTR szFile, LPCLSID lpclsid) ...@@ -156,7 +156,7 @@ static BOOL AVIFILE_GetFileHandlerByExtension(LPCWSTR szFile, LPCLSID lpclsid)
CHAR szRegKey[25]; CHAR szRegKey[25];
CHAR szValue[100]; CHAR szValue[100];
LPWSTR szExt = strrchrW(szFile, '.'); LPWSTR szExt = strrchrW(szFile, '.');
LONG len = sizeof(szValue) / sizeof(szValue[0]); LONG len = ARRAY_SIZE(szValue);
if (szExt == NULL) if (szExt == NULL)
return FALSE; return FALSE;
...@@ -371,7 +371,7 @@ HRESULT WINAPI AVIFileCreateStreamA(PAVIFILE pfile, PAVISTREAM *ppavi, ...@@ -371,7 +371,7 @@ HRESULT WINAPI AVIFileCreateStreamA(PAVIFILE pfile, PAVISTREAM *ppavi,
/* Only the szName at the end is different */ /* Only the szName at the end is different */
memcpy(&psiw, psi, sizeof(*psi) - sizeof(psi->szName)); memcpy(&psiw, psi, sizeof(*psi) - sizeof(psi->szName));
MultiByteToWideChar(CP_ACP, 0, psi->szName, -1, psiw.szName, MultiByteToWideChar(CP_ACP, 0, psi->szName, -1, psiw.szName,
sizeof(psiw.szName) / sizeof(psiw.szName[0])); ARRAY_SIZE(psiw.szName));
return IAVIFile_CreateStream(pfile, ppavi, &psiw); return IAVIFile_CreateStream(pfile, ppavi, &psiw);
} }
...@@ -1035,7 +1035,7 @@ HRESULT WINAPI AVIBuildFilterW(LPWSTR szFilter, LONG cbFilter, BOOL fSaving) ...@@ -1035,7 +1035,7 @@ HRESULT WINAPI AVIBuildFilterW(LPWSTR szFilter, LONG cbFilter, BOOL fSaving)
HeapFree(GetProcessHeap(), 0, lp); HeapFree(GetProcessHeap(), 0, lp);
return AVIERR_ERROR; return AVIERR_ERROR;
} }
for (n = 0;RegEnumKeyW(hKey, n, szFileExt, sizeof(szFileExt)/sizeof(szFileExt[0])) == ERROR_SUCCESS;n++) { for (n = 0;RegEnumKeyW(hKey, n, szFileExt, ARRAY_SIZE(szFileExt)) == ERROR_SUCCESS;n++) {
WCHAR clsidW[40]; WCHAR clsidW[40];
/* get CLSID to extension */ /* get CLSID to extension */
...@@ -1300,7 +1300,7 @@ static void AVISaveOptionsUpdate(HWND hWnd) ...@@ -1300,7 +1300,7 @@ static void AVISaveOptionsUpdate(HWND hWnd)
} else { } else {
LoadStringW(AVIFILE_hModule, IDS_UNCOMPRESSED, LoadStringW(AVIFILE_hModule, IDS_UNCOMPRESSED,
icinfo.szDescription, icinfo.szDescription,
sizeof(icinfo.szDescription)/sizeof(icinfo.szDescription[0])); ARRAY_SIZE(icinfo.szDescription));
lstrcatW(szFormat, icinfo.szDescription); lstrcatW(szFormat, icinfo.szDescription);
} }
} else if (sInfo.fccType == streamtypeAUDIO) { } else if (sInfo.fccType == streamtypeAUDIO) {
...@@ -2160,7 +2160,7 @@ HRESULT WINAPI EditStreamSetNameA(PAVISTREAM pstream, LPCSTR szName) ...@@ -2160,7 +2160,7 @@ HRESULT WINAPI EditStreamSetNameA(PAVISTREAM pstream, LPCSTR szName)
return hres; return hres;
memset(asia.szName, 0, sizeof(asia.szName)); memset(asia.szName, 0, sizeof(asia.szName));
lstrcpynA(asia.szName, szName, sizeof(asia.szName)/sizeof(asia.szName[0])); lstrcpynA(asia.szName, szName, ARRAY_SIZE(asia.szName));
return EditStreamSetInfoA(pstream, &asia, sizeof(asia)); return EditStreamSetInfoA(pstream, &asia, sizeof(asia));
} }
...@@ -2185,7 +2185,7 @@ HRESULT WINAPI EditStreamSetNameW(PAVISTREAM pstream, LPCWSTR szName) ...@@ -2185,7 +2185,7 @@ HRESULT WINAPI EditStreamSetNameW(PAVISTREAM pstream, LPCWSTR szName)
return hres; return hres;
memset(asiw.szName, 0, sizeof(asiw.szName)); memset(asiw.szName, 0, sizeof(asiw.szName));
lstrcpynW(asiw.szName, szName, sizeof(asiw.szName)/sizeof(asiw.szName[0])); lstrcpynW(asiw.szName, szName, ARRAY_SIZE(asiw.szName));
return EditStreamSetInfoW(pstream, &asiw, sizeof(asiw)); return EditStreamSetInfoW(pstream, &asiw, sizeof(asiw));
} }
......
...@@ -1641,7 +1641,7 @@ static HRESULT AVIFILE_LoadFile(IAVIFileImpl *This) ...@@ -1641,7 +1641,7 @@ static HRESULT AVIFILE_LoadFile(IAVIFileImpl *This)
This->fInfo.dwWidth = MainAVIHdr.dwWidth; This->fInfo.dwWidth = MainAVIHdr.dwWidth;
This->fInfo.dwHeight = MainAVIHdr.dwHeight; This->fInfo.dwHeight = MainAVIHdr.dwHeight;
LoadStringW(AVIFILE_hModule, IDS_AVIFILETYPE, This->fInfo.szFileType, LoadStringW(AVIFILE_hModule, IDS_AVIFILETYPE, This->fInfo.szFileType,
sizeof(This->fInfo.szFileType)/sizeof(This->fInfo.szFileType[0])); ARRAY_SIZE(This->fInfo.szFileType));
/* go back to into header list */ /* go back to into header list */
if (mmioAscend(This->hmmio, &ck, 0) != S_OK) if (mmioAscend(This->hmmio, &ck, 0) != S_OK)
...@@ -1751,9 +1751,9 @@ static HRESULT AVIFILE_LoadFile(IAVIFileImpl *This) ...@@ -1751,9 +1751,9 @@ static HRESULT AVIFILE_LoadFile(IAVIFileImpl *This)
/* generate description for stream like "filename.avi Type #n" */ /* generate description for stream like "filename.avi Type #n" */
if (streamHdr.fccType == streamtypeVIDEO) if (streamHdr.fccType == streamtypeVIDEO)
LoadStringW(AVIFILE_hModule, IDS_VIDEO, szType, sizeof(szType)/sizeof(szType[0])); LoadStringW(AVIFILE_hModule, IDS_VIDEO, szType, ARRAY_SIZE(szType));
else if (streamHdr.fccType == streamtypeAUDIO) else if (streamHdr.fccType == streamtypeAUDIO)
LoadStringW(AVIFILE_hModule, IDS_AUDIO, szType, sizeof(szType)/sizeof(szType[0])); LoadStringW(AVIFILE_hModule, IDS_AUDIO, szType, ARRAY_SIZE(szType));
else else
wsprintfW(szType, streamTypeFmt, (char*)&streamHdr.fccType); wsprintfW(szType, streamTypeFmt, (char*)&streamHdr.fccType);
...@@ -1784,7 +1784,7 @@ static HRESULT AVIFILE_LoadFile(IAVIFileImpl *This) ...@@ -1784,7 +1784,7 @@ static HRESULT AVIFILE_LoadFile(IAVIFileImpl *This)
} }
MultiByteToWideChar(CP_ACP, 0, str, -1, pStream->sInfo.szName, MultiByteToWideChar(CP_ACP, 0, str, -1, pStream->sInfo.szName,
sizeof(pStream->sInfo.szName)/sizeof(pStream->sInfo.szName[0])); ARRAY_SIZE(pStream->sInfo.szName));
HeapFree(GetProcessHeap(), 0, str); HeapFree(GetProcessHeap(), 0, str);
} }
......
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
#include <windef.h> #include <windef.h>
#include <winuser.h> #include <winuser.h>
#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
#ifndef MAX_AVISTREAMS #ifndef MAX_AVISTREAMS
#define MAX_AVISTREAMS 8 #define MAX_AVISTREAMS 8
#endif #endif
......
...@@ -522,9 +522,9 @@ static HRESULT WINAPI IPersistFile_fnLoad(IPersistFile *iface, LPCOLESTR pszFile ...@@ -522,9 +522,9 @@ static HRESULT WINAPI IPersistFile_fnLoad(IPersistFile *iface, LPCOLESTR pszFile
memset(& This->sInfo, 0, sizeof(This->sInfo)); memset(& This->sInfo, 0, sizeof(This->sInfo));
LoadStringW(AVIFILE_hModule, IDS_WAVEFILETYPE, This->fInfo.szFileType, LoadStringW(AVIFILE_hModule, IDS_WAVEFILETYPE, This->fInfo.szFileType,
sizeof(This->fInfo.szFileType)/sizeof(This->fInfo.szFileType[0])); ARRAY_SIZE(This->fInfo.szFileType));
if (LoadStringW(AVIFILE_hModule, IDS_WAVESTREAMFORMAT, if (LoadStringW(AVIFILE_hModule, IDS_WAVESTREAMFORMAT,
wszStreamFmt, sizeof(wszStreamFmt)/sizeof(wszStreamFmt[0])) > 0) { wszStreamFmt, ARRAY_SIZE(wszStreamFmt)) > 0) {
wsprintfW(This->sInfo.szName, wszStreamFmt, wsprintfW(This->sInfo.szName, wszStreamFmt,
AVIFILE_BasenameW(This->szFileName)); AVIFILE_BasenameW(This->szFileName));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment