Fixed compiling and tested on Windows
authorSam Lantinga <slouken@libsdl.org>
Thu, 28 May 2015 12:06:48 -0700
changeset 9672bc1ba207ff16
parent 9671 0e1f57b051f4
child 9673 aea5a2032785
Fixed compiling and tested on Windows
src/filesystem/windows/SDL_sysfilesystem.c
     1.1 --- a/src/filesystem/windows/SDL_sysfilesystem.c	Thu May 28 01:54:52 2015 -0400
     1.2 +++ b/src/filesystem/windows/SDL_sysfilesystem.c	Thu May 28 12:06:48 2015 -0700
     1.3 @@ -36,19 +36,21 @@
     1.4  char *
     1.5  SDL_GetBasePath(void)
     1.6  {
     1.7 -    DWORD (WINAPI * pGetModuleFileNameExW)(HANDLE, HMODULE, LPWSTR, DWORD) = NULL;
     1.8 +    typedef DWORD (WINAPI *GetModuleFileNameExW_t)(HANDLE, HMODULE, LPWSTR, DWORD);
     1.9 +    GetModuleFileNameExW_t pGetModuleFileNameExW;
    1.10      DWORD buflen = 128;
    1.11      WCHAR *path = NULL;
    1.12      HANDLE psapi = LoadLibrary(L"psapi.dll");
    1.13      char *retval = NULL;
    1.14      DWORD len = 0;
    1.15 +    int i;
    1.16  
    1.17      if (!psapi) {
    1.18          WIN_SetError("Couldn't load psapi.dll");
    1.19          return NULL;
    1.20      }
    1.21  
    1.22 -    pGetModuleFileNameExW = GetProcAddress(psapi, "GetModuleFileNameExW");
    1.23 +    pGetModuleFileNameExW = (GetModuleFileNameExW_t)GetProcAddress(psapi, "GetModuleFileNameExW");
    1.24      if (!pGetModuleFileNameExW) {
    1.25          WIN_SetError("Couldn't find GetModuleFileNameExW");
    1.26          FreeLibrary(psapi);
    1.27 @@ -56,14 +58,14 @@
    1.28      }
    1.29  
    1.30      while (SDL_TRUE) {
    1.31 -        path = (WCHAR *) SDL_malloc(path, buflen * sizeof (WCHAR));
    1.32 +        path = (WCHAR *)SDL_realloc(path, buflen * sizeof (WCHAR));
    1.33          if (!path) {
    1.34              FreeLibrary(psapi);
    1.35              SDL_OutOfMemory();
    1.36              return NULL;
    1.37          }
    1.38  
    1.39 -        len = pGetModuleFileNameEx(GetCurrentProcess(), NULL, path, buflen);
    1.40 +        len = pGetModuleFileNameExW(GetCurrentProcess(), NULL, path, buflen);
    1.41          if (len != buflen) {
    1.42              break;
    1.43          }