mirror of
https://github.com/nicbarker/clay.git
synced 2025-04-19 12:48:05 +00:00
[Examples/Intro] Fix NULL pointer deref due to huuge malloc
It would probably be good to check that malloc doesn't fail, but for a simple example like this it should be fine.
This commit is contained in:
parent
37af99b221
commit
c72972fea2
@ -79,10 +79,7 @@ int main(void) {
|
|||||||
Clay_Raylib_Initialize(1024, 768, "Introducing Clay Demo", FLAG_WINDOW_RESIZABLE | FLAG_WINDOW_HIGHDPI | FLAG_MSAA_4X_HINT | FLAG_VSYNC_HINT); // Extra parameters to this function are new since the video was published
|
Clay_Raylib_Initialize(1024, 768, "Introducing Clay Demo", FLAG_WINDOW_RESIZABLE | FLAG_WINDOW_HIGHDPI | FLAG_MSAA_4X_HINT | FLAG_VSYNC_HINT); // Extra parameters to this function are new since the video was published
|
||||||
|
|
||||||
uint64_t clayRequiredMemory = Clay_MinMemorySize();
|
uint64_t clayRequiredMemory = Clay_MinMemorySize();
|
||||||
Clay_Arena clayMemory = (Clay_Arena) {
|
Clay_Arena clayMemory = Clay_CreateArenaWithCapacityAndMemory(clayRequiredMemory, malloc(clayRequiredMemory));
|
||||||
.memory = malloc((size_t)1024 * 1024 * 1024 * 1024),
|
|
||||||
.capacity = clayRequiredMemory
|
|
||||||
};
|
|
||||||
Clay_Initialize(clayMemory, (Clay_Dimensions) {
|
Clay_Initialize(clayMemory, (Clay_Dimensions) {
|
||||||
.width = GetScreenWidth(),
|
.width = GetScreenWidth(),
|
||||||
.height = GetScreenHeight()
|
.height = GetScreenHeight()
|
||||||
@ -302,4 +299,4 @@ int main(void) {
|
|||||||
Clay_Raylib_Render(renderCommands);
|
Clay_Raylib_Render(renderCommands);
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user