Added __attribute__ nonnull/pure/const to some GraphX prototypes #584
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've added a few function
__atrribute__'s tographx.h. This can help with optimization, and safety.Changes:
gfx_AllocSpriteandgfx_ConvertToNewRLETSpritetake a function pointer to a malloc routine, so I've added__nonnull__to that parameter since these routines do not check if the function pointer isNULL.gfx_Lightenandgfx_Darkenare__const__functions as the same inputs will always generate the same output.gfx_GetTextX,gfx_GetTextY,gfx_GetCharWidth, andgfx_GetStringWidthare__pure__functions, as they read from non-volatile addresses.@note sprite_in and sprite_out cannot be the same, so I've added__restrictto both parameters, which can then allow the compiler to warn about it.gfx_TilePtrandgfx_TilePtrMappedare__pure__since they only read from the parameters passed into the function.Other things that could be done later on:
gfx_GetPixelmight be__pure__, but that depends on if we consider reading from vram to be volatile or not__nonnull__could be applied to most sprite routines, as they don't appear to check if the sprite pointer isNULLgraphx.hmight look like this with all applicable compiler directives https://github.com/ZERICO2005/toolchain/blob/graphy/src/graphx/graphx.h