Fixed compiling and tested on Windows
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
diff --git a/src/filesystem/windows/SDL_sysfilesystem.c b/src/filesystem/windows/SDL_sysfilesystem.c
index 1e1206b..e4e9f74 100644
--- a/src/filesystem/windows/SDL_sysfilesystem.c
+++ b/src/filesystem/windows/SDL_sysfilesystem.c
@@ -36,19 +36,21 @@
char *
SDL_GetBasePath(void)
{
- DWORD (WINAPI * pGetModuleFileNameExW)(HANDLE, HMODULE, LPWSTR, DWORD) = NULL;
+ typedef DWORD (WINAPI *GetModuleFileNameExW_t)(HANDLE, HMODULE, LPWSTR, DWORD);
+ GetModuleFileNameExW_t pGetModuleFileNameExW;
DWORD buflen = 128;
WCHAR *path = NULL;
HANDLE psapi = LoadLibrary(L"psapi.dll");
char *retval = NULL;
DWORD len = 0;
+ int i;
if (!psapi) {
WIN_SetError("Couldn't load psapi.dll");
return NULL;
}
- pGetModuleFileNameExW = GetProcAddress(psapi, "GetModuleFileNameExW");
+ pGetModuleFileNameExW = (GetModuleFileNameExW_t)GetProcAddress(psapi, "GetModuleFileNameExW");
if (!pGetModuleFileNameExW) {
WIN_SetError("Couldn't find GetModuleFileNameExW");
FreeLibrary(psapi);
@@ -56,14 +58,14 @@ SDL_GetBasePath(void)
}
while (SDL_TRUE) {
- path = (WCHAR *) SDL_malloc(path, buflen * sizeof (WCHAR));
+ path = (WCHAR *)SDL_realloc(path, buflen * sizeof (WCHAR));
if (!path) {
FreeLibrary(psapi);
SDL_OutOfMemory();
return NULL;
}
- len = pGetModuleFileNameEx(GetCurrentProcess(), NULL, path, buflen);
+ len = pGetModuleFileNameExW(GetCurrentProcess(), NULL, path, buflen);
if (len != buflen) {
break;
}