mirror of
https://github.com/raysan5/raylib.git
synced 2026-04-09 16:59:09 -04:00
REVIEWED: examples memory allocators, using raylib provided macros
This commit is contained in:
@ -47,7 +47,7 @@ int main(void)
|
||||
// Load bunny texture
|
||||
Texture2D texBunny = LoadTexture("resources/raybunny.png");
|
||||
|
||||
Bunny *bunnies = (Bunny *)malloc(MAX_BUNNIES*sizeof(Bunny)); // Bunnies array
|
||||
Bunny *bunnies = (Bunny *)RL_MALLOC(MAX_BUNNIES*sizeof(Bunny)); // Bunnies array
|
||||
|
||||
int bunniesCount = 0; // Bunnies counter
|
||||
|
||||
@ -126,7 +126,7 @@ int main(void)
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
free(bunnies); // Unload bunnies data array
|
||||
RL_FREE(bunnies); // Unload bunnies data array
|
||||
|
||||
UnloadTexture(texBunny); // Unload bunny texture
|
||||
|
||||
|
||||
@ -51,8 +51,8 @@ int main(void)
|
||||
// NOTE: We can have up to 256 values for tile ids and for tile fog state,
|
||||
// probably we don't need that many values for fog state, it can be optimized
|
||||
// to use only 2 bits per fog state (reducing size by 4) but logic will be a bit more complex
|
||||
map.tileIds = (unsigned char *)calloc(map.tilesX*map.tilesY, sizeof(unsigned char));
|
||||
map.tileFog = (unsigned char *)calloc(map.tilesX*map.tilesY, sizeof(unsigned char));
|
||||
map.tileIds = (unsigned char *)RL_CALLOC(map.tilesX*map.tilesY, sizeof(unsigned char));
|
||||
map.tileFog = (unsigned char *)RL_CALLOC(map.tilesX*map.tilesY, sizeof(unsigned char));
|
||||
|
||||
// Load map tiles (generating 2 random tile ids for testing)
|
||||
// NOTE: Map tile ids should be probably loaded from an external map file
|
||||
@ -149,8 +149,8 @@ int main(void)
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
free(map.tileIds); // Free allocated map tile ids
|
||||
free(map.tileFog); // Free allocated map tile fog state
|
||||
RL_FREE(map.tileIds); // Free allocated map tile ids
|
||||
RL_FREE(map.tileFog); // Free allocated map tile fog state
|
||||
|
||||
UnloadRenderTexture(fogOfWar); // Unload render texture
|
||||
|
||||
|
||||
Reference in New Issue
Block a user