Skip to content

Commit 6e58912

Browse files
ZERICO2005mateoconlechuga
authored andcommitted
Added __attribute__ nonnull/pure/const to some GraphX prototypes
1 parent 2af012c commit 6e58912

File tree

1 file changed

+30
-24
lines changed

1 file changed

+30
-24
lines changed

src/graphx/graphx.h

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,8 @@ void gfx_End(void);
621621
*/
622622
gfx_sprite_t *gfx_AllocSprite(uint8_t width,
623623
uint8_t height,
624-
void *(*malloc_routine)(size_t));
624+
void *(*malloc_routine)(size_t)
625+
) __attribute__((__nonnull__(3)));
625626

626627
/**
627628
* Draws a tilemap.
@@ -681,7 +682,8 @@ void gfx_TransparentTilemap_NoClip(const gfx_tilemap_t *tilemap,
681682
*/
682683
uint8_t *gfx_TilePtr(const gfx_tilemap_t *tilemap,
683684
uint24_t x_offset,
684-
uint24_t y_offset);
685+
uint24_t y_offset
686+
) __attribute__((__pure__));
685687

686688
/**
687689
* Gets a pointer to a particular sprite tileset index.
@@ -693,7 +695,8 @@ uint8_t *gfx_TilePtr(const gfx_tilemap_t *tilemap,
693695
*/
694696
uint8_t *gfx_TilePtrMapped(const gfx_tilemap_t *tilemap,
695697
uint8_t col,
696-
uint8_t row);
698+
uint8_t row
699+
) __attribute__((__pure__));
697700

698701
/**
699702
* Sets the color index that drawing routines will use
@@ -1214,12 +1217,12 @@ void gfx_PrintStringXY(const char *string, int x, int y);
12141217
/**
12151218
* @returns The current text cursor X position.
12161219
*/
1217-
int gfx_GetTextX(void);
1220+
int gfx_GetTextX(void) __attribute__((__pure__));
12181221

12191222
/**
12201223
* @returns The current text cursor Y position.
12211224
*/
1222-
int gfx_GetTextY(void);
1225+
int gfx_GetTextY(void) __attribute__((__pure__));
12231226

12241227
/**
12251228
* Sets the text cursor X and Y positions.
@@ -1401,8 +1404,8 @@ uint8_t gfx_RotatedScaledSprite_NoClip(const gfx_sprite_t *sprite,
14011404
* @returns A pointer to sprite_out.
14021405
* @note sprite_in and sprite_out cannot be the same. Ensure sprite_out is allocated.
14031406
*/
1404-
gfx_sprite_t *gfx_FlipSpriteX(const gfx_sprite_t *sprite_in,
1405-
gfx_sprite_t *sprite_out);
1407+
gfx_sprite_t *gfx_FlipSpriteX(const gfx_sprite_t *__restrict sprite_in,
1408+
gfx_sprite_t *__restrict sprite_out);
14061409

14071410
/**
14081411
* Flips a sprite along the Y axis.
@@ -1412,8 +1415,8 @@ gfx_sprite_t *gfx_FlipSpriteX(const gfx_sprite_t *sprite_in,
14121415
* @returns A pointer to sprite_out.
14131416
* @note sprite_in and sprite_out cannot be the same. Ensure sprite_out is allocated.
14141417
*/
1415-
gfx_sprite_t *gfx_FlipSpriteY(const gfx_sprite_t *sprite_in,
1416-
gfx_sprite_t *sprite_out);
1418+
gfx_sprite_t *gfx_FlipSpriteY(const gfx_sprite_t *__restrict sprite_in,
1419+
gfx_sprite_t *__restrict sprite_out);
14171420

14181421
/**
14191422
* Rotates a sprite 90 degrees clockwise.
@@ -1423,8 +1426,8 @@ gfx_sprite_t *gfx_FlipSpriteY(const gfx_sprite_t *sprite_in,
14231426
* @returns A pointer to sprite_out.
14241427
* @note sprite_in and sprite_out cannot be the same. Ensure sprite_out is allocated.
14251428
*/
1426-
gfx_sprite_t *gfx_RotateSpriteC(const gfx_sprite_t *sprite_in,
1427-
gfx_sprite_t *sprite_out);
1429+
gfx_sprite_t *gfx_RotateSpriteC(const gfx_sprite_t *__restrict sprite_in,
1430+
gfx_sprite_t *__restrict sprite_out);
14281431

14291432
/**
14301433
* Rotates a sprite 90 degrees counter clockwise.
@@ -1434,8 +1437,8 @@ gfx_sprite_t *gfx_RotateSpriteC(const gfx_sprite_t *sprite_in,
14341437
* @returns A pointer to sprite_out.
14351438
* @note sprite_in and sprite_out cannot be the same. Ensure sprite_out is allocated.
14361439
*/
1437-
gfx_sprite_t *gfx_RotateSpriteCC(const gfx_sprite_t *sprite_in,
1438-
gfx_sprite_t *sprite_out);
1440+
gfx_sprite_t *gfx_RotateSpriteCC(const gfx_sprite_t *__restrict sprite_in,
1441+
gfx_sprite_t *__restrict sprite_out);
14391442

14401443
/**
14411444
* Rotates a sprite 180 degrees.
@@ -1445,8 +1448,8 @@ gfx_sprite_t *gfx_RotateSpriteCC(const gfx_sprite_t *sprite_in,
14451448
* @returns A pointer to sprite_out.
14461449
* @note sprite_in and sprite_out cannot be the same. Ensure sprite_out is allocated.
14471450
*/
1448-
gfx_sprite_t *gfx_RotateSpriteHalf(const gfx_sprite_t *sprite_in,
1449-
gfx_sprite_t *sprite_out);
1451+
gfx_sprite_t *gfx_RotateSpriteHalf(const gfx_sprite_t *__restrict sprite_in,
1452+
gfx_sprite_t *__restrict sprite_out);
14501453

14511454
/**
14521455
* Resizes a sprite to new dimensions.
@@ -1458,8 +1461,8 @@ gfx_sprite_t *gfx_RotateSpriteHalf(const gfx_sprite_t *sprite_in,
14581461
* @returns A pointer to \p sprite_out.
14591462
* @note sprite_in and sprite_out cannot be the same. Ensure sprite_out is allocated.
14601463
*/
1461-
gfx_sprite_t *gfx_ScaleSprite(const gfx_sprite_t *sprite_in,
1462-
gfx_sprite_t *sprite_out);
1464+
gfx_sprite_t *gfx_ScaleSprite(const gfx_sprite_t *__restrict sprite_in,
1465+
gfx_sprite_t *__restrict sprite_out);
14631466

14641467
/**
14651468
* Fixed Rotation with scaling factor for sprites.
@@ -1479,8 +1482,8 @@ gfx_sprite_t *gfx_ScaleSprite(const gfx_sprite_t *sprite_in,
14791482
* @returns A pointer to \p sprite_out.
14801483
* @note sprite_in and sprite_out cannot be the same. Ensure sprite_out is allocated.
14811484
*/
1482-
gfx_sprite_t *gfx_RotateScaleSprite(const gfx_sprite_t *sprite_in,
1483-
gfx_sprite_t *sprite_out,
1485+
gfx_sprite_t *gfx_RotateScaleSprite(const gfx_sprite_t *__restrict sprite_in,
1486+
gfx_sprite_t *__restrict sprite_out,
14841487
uint8_t angle,
14851488
uint8_t scale);
14861489

@@ -1554,7 +1557,7 @@ void gfx_SetMonospaceFont(uint8_t spacing);
15541557
* @param[in] string Pointer to a string.
15551558
* @note Takes into account monospacing flag.
15561559
*/
1557-
unsigned int gfx_GetStringWidth(const char *string);
1560+
unsigned int gfx_GetStringWidth(const char *string) __attribute__((__pure__));
15581561

15591562
/**
15601563
* Gets the pixel width of the given character.
@@ -1563,7 +1566,7 @@ unsigned int gfx_GetStringWidth(const char *string);
15631566
* @returns Width in pixels of character.
15641567
* @note Takes into account monospacing flag.
15651568
*/
1566-
unsigned int gfx_GetCharWidth(const char c);
1569+
unsigned int gfx_GetCharWidth(const char c) __attribute__((__pure__));
15671570

15681571
/**
15691572
* Sets the dimensions of the drawing window for all clipped routines.
@@ -1623,7 +1626,8 @@ void gfx_ShiftRight(uint24_t pixels);
16231626
* @note 0 returns full white, 255 returns original color.
16241627
*/
16251628
uint16_t gfx_Lighten(uint16_t color,
1626-
uint8_t amount);
1629+
uint8_t amount
1630+
) __attribute__((__const__));
16271631

16281632
/**
16291633
* Darkens a given 1555 color; useful for palette color conversions.
@@ -1634,7 +1638,8 @@ uint16_t gfx_Lighten(uint16_t color,
16341638
* @note 0 returns full black, 255 returns original color.
16351639
*/
16361640
uint16_t gfx_Darken(uint16_t color,
1637-
uint8_t amount);
1641+
uint8_t amount
1642+
) __attribute__((__const__));
16381643

16391644
/**
16401645
* Fills an area with a color.
@@ -1744,7 +1749,8 @@ gfx_rletsprite_t *gfx_ConvertToRLETSprite(const gfx_sprite_t *sprite_in,
17441749
* @see gfx_ConvertFromRLETSprite.
17451750
*/
17461751
gfx_rletsprite_t *gfx_ConvertToNewRLETSprite(const gfx_sprite_t *sprite_in,
1747-
void *(*malloc_routine)(size_t));
1752+
void *(*malloc_routine)(size_t)
1753+
) __attribute__((__nonnull__(2)));
17481754

17491755
/* Compatibility defines (don't use please) */
17501756
/* @cond */

0 commit comments

Comments
 (0)