mirror of
https://github.com/glfw/glfw.git
synced 2024-11-23 02:25:10 +00:00
Delayed window struct allocation.
This commit is contained in:
parent
98eb79b7d9
commit
d1d550d1ab
29
src/window.c
29
src/window.c
@ -327,17 +327,8 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
window = (_GLFWwindow*) _glfwMalloc(sizeof(_GLFWwindow));
|
||||
if (!window)
|
||||
{
|
||||
_glfwSetError(GLFW_OUT_OF_MEMORY, "glfwOpenWindow: Failed to allocate window structure");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(window, 0, sizeof(_GLFWwindow));
|
||||
|
||||
window->next = _glfwLibrary.windowListHead;
|
||||
_glfwLibrary.windowListHead = window;
|
||||
// We need to copy these values before doing anything that can fail, as the
|
||||
// window hints should be cleared after each call even if it fails
|
||||
|
||||
// Set up desired framebuffer config
|
||||
fbconfig.redBits = Max(_glfwLibrary.hints.redBits, 0);
|
||||
@ -371,14 +362,10 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height,
|
||||
|
||||
// Check the OpenGL bits of the window config
|
||||
if (!isValidContextConfig(&wndconfig))
|
||||
{
|
||||
glfwCloseWindow(window);
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
if (mode != GLFW_WINDOWED && mode != GLFW_FULLSCREEN)
|
||||
{
|
||||
glfwCloseWindow(window);
|
||||
_glfwSetError(GLFW_INVALID_ENUM, "glfwOpenWindow: Invalid enum for 'mode' parameter");
|
||||
return GL_FALSE;
|
||||
}
|
||||
@ -401,6 +388,18 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height,
|
||||
height = 480;
|
||||
}
|
||||
|
||||
window = (_GLFWwindow*) _glfwMalloc(sizeof(_GLFWwindow));
|
||||
if (!window)
|
||||
{
|
||||
_glfwSetError(GLFW_OUT_OF_MEMORY, "glfwOpenWindow: Failed to allocate window structure");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(window, 0, sizeof(_GLFWwindow));
|
||||
|
||||
window->next = _glfwLibrary.windowListHead;
|
||||
_glfwLibrary.windowListHead = window;
|
||||
|
||||
// Remember window settings
|
||||
window->width = width;
|
||||
window->height = height;
|
||||
|
Loading…
Reference in New Issue
Block a user