REVIEWED: examples memory allocators, using raylib provided macros
This commit is contained in:
parent
7e8aca00b6
commit
ca1baca7c2
5 changed files with 59 additions and 53 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue