fix C89 forbidden mixed declarations

This commit is contained in:
Bayemite 2021-06-03 22:02:24 +10:00
parent 5ddb905a6a
commit 3c44229af8
3 changed files with 24 additions and 18 deletions

View File

@ -1464,11 +1464,14 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
char* _glfwPlatformGetWindowTitle(_GLFWwindow* window) char* _glfwPlatformGetWindowTitle(_GLFWwindow* window)
{ {
int count = GetWindowTextLengthW(window->win32.handle); int count;
SetLastError(0);
count = GetWindowTextLengthW(window->win32.handle);
if(count == 0) if(count == 0)
{ {
SetLastError(0); int error;
int error = GetLastError(); error = GetLastError();
if(error != 0) if(error != 0)
{ {
@ -1481,11 +1484,14 @@ char* _glfwPlatformGetWindowTitle(_GLFWwindow* window)
} }
else else
{ {
WCHAR* wideTitle;
char* title;
count += 1; // the \0 count += 1; // the \0
WCHAR* wideTitle = calloc(count, sizeof(WCHAR));
wideTitle = calloc(count, sizeof(WCHAR));
GetWindowTextW(window->win32.handle, wideTitle, count); GetWindowTextW(window->win32.handle, wideTitle, count);
char* title = _glfwCreateUTF8FromWideStringWin32(wideTitle); title = _glfwCreateUTF8FromWideStringWin32(wideTitle);
if(!title) if(!title)
return calloc(1, sizeof(char)); // single \0 return calloc(1, sizeof(char)); // single \0