* [rcore] fix crash in InitWindow, due to unchecked result of InitPlatform
Check the result of InitPlatform(), if it isn't 0, report the Error
and return. This prevent crashes and allows for gracefully aborting
or recovering by checking IsWindowReady().
Partially-fixes: https://github.com/raysan5/raylib/issues/4801
* [rcore] style: store the result of InitPlatform() before checking it
Small style change that doesn't impact how the code behaves here.
Variable 'result' is not used anywhere else in this block,
it's just for compliance with Raylib's coding conventions.
Requested in PR: https://github.com/raysan5/raylib/pull/4803#discussion_r1976502788
* [rcore] use LOG_WARNING when InitPlatform() fails
...as this is preferred over LOG_ERROR.
Requested-by: https://github.com/raysan5/raylib/pull/4803#discussion_r1976651724
In the case of a failure within miniaudio on the function: ma_convert_frames, the dynamic memory allocated for the `data` variable will leak on the early return.
Raylib allows for providing custom allocators via macros.
GLFW supports this too, but via function pointers.
Make sure that GLFW uses those Raylib macros, by wrapping them in
function calls and setting them up inside of InitPlatform().
This is possible because of glfwInitAllocator() and GLFWallocator.
Fixes: https://github.com/raysan5/raylib/issues/4776
Relates-to: https://github.com/raysan5/raylib/issues/4751
I was really wondering what is going on here :D I believe this code
tried initially to out-cast 'const' specifier but this is not needed here
at all. Currently, it just confuses whoever reads this so I changed it.
The old code would also trigger -Wcast-qual warning on some compilers.
Currently, a warning about _GNU_SOURCE being redefined is emitted when
compiling rglfw.c
In file included from rglfw.c:99:
external/glfw/src/posix_poll.c:27:9: warning: "_GNU_SOURCE" redefined
27 | #define _GNU_SOURCE
| ^~~~~~~~~~~
<command-line>: note: this is the location of the previous definition
This can be avoided by not defining _GNU_SOURCE on the command line for
this file.
Defining feature test macros in source code is not really good practice
so this should probably reviewed in glfw itself, at least to maybe check
#ifdef _GNU_SOURCE first. But for now this change will suffice.
Fixes#4725