From c800fec625521c9cb791d69933c8084e390c2bd0 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sat, 26 Feb 2022 14:49:53 +0000 Subject: API: Consistent typedef naming convention. --- include/nsgif.h | 26 ++++++++++++++------------ src/gif.c | 30 ++++++++++++++++-------------- test/nsgif.c | 6 +++--- 3 files changed, 33 insertions(+), 29 deletions(-) diff --git a/include/nsgif.h b/include/nsgif.h index b36af8a..2c8a60c 100644 --- a/include/nsgif.h +++ b/include/nsgif.h @@ -23,7 +23,7 @@ /** Representation of infinity. */ #define NSGIF_INFINITE (UINT32_MAX) -typedef struct nsgif nsgif; +typedef struct nsgif nsgif_t; /** * GIF rectangle structure. @@ -42,7 +42,7 @@ typedef struct nsgif_rect { uint32_t x1; /** y co-ordinate of redraw rectangle, bottom */ uint32_t y1; -} nsgif_rect; +} nsgif_rect_t; /** * NSGIF return codes. @@ -178,14 +178,16 @@ const char *nsgif_strerror(nsgif_error err); * * \return NSGIF_OK on success, or appropriate error otherwise. */ -nsgif_error nsgif_create(const nsgif_bitmap_cb_vt *bitmap_vt, nsgif **gif_out); +nsgif_error nsgif_create( + const nsgif_bitmap_cb_vt *bitmap_vt, + nsgif_t **gif_out); /** * Free a NSGIF object. * * \param[in] gif The NSGIF to free. */ -void nsgif_destroy(nsgif *gif); +void nsgif_destroy(nsgif_t *gif); /** * Scan the source image data. @@ -212,7 +214,7 @@ void nsgif_destroy(nsgif *gif); * \return NSGIF_OK on success, or appropriate error otherwise. */ nsgif_error nsgif_data_scan( - nsgif *gif, + nsgif_t *gif, size_t size, const uint8_t *data); @@ -231,8 +233,8 @@ nsgif_error nsgif_data_scan( * \return NSGIF_OK on success, or appropriate error otherwise. */ nsgif_error nsgif_frame_prepare( - nsgif *gif, - nsgif_rect *area, + nsgif_t *gif, + nsgif_rect_t *area, uint32_t *delay_cs, uint32_t *frame_new); @@ -247,7 +249,7 @@ nsgif_error nsgif_frame_prepare( * \return NSGIF_OK on success, or appropriate error otherwise. */ nsgif_error nsgif_frame_decode( - nsgif *gif, + nsgif_t *gif, uint32_t frame, nsgif_bitmap_t **bitmap); @@ -264,7 +266,7 @@ nsgif_error nsgif_frame_decode( * \return NSGIF_OK on success, or appropriate error otherwise. */ nsgif_error nsgif_reset( - nsgif *gif); + nsgif_t *gif); /** * Information about a GIF. @@ -317,7 +319,7 @@ typedef struct nsgif_frame_info { uint32_t delay; /** Frame's redraw rectangle. */ - nsgif_rect rect; + nsgif_rect_t rect; } nsgif_frame_info_t; /** @@ -327,7 +329,7 @@ typedef struct nsgif_frame_info { * * \return The gif info, or NULL on error. */ -const nsgif_info_t *nsgif_get_info(const nsgif *gif); +const nsgif_info_t *nsgif_get_info(const nsgif_t *gif); /** * Get information about a GIF from an NSGIF object. @@ -338,7 +340,7 @@ const nsgif_info_t *nsgif_get_info(const nsgif *gif); * \return The gif frame info, or NULL on error. */ const nsgif_frame_info_t *nsgif_get_frame_info( - const nsgif *gif, + const nsgif_t *gif, uint32_t frame); #endif diff --git a/src/gif.c b/src/gif.c index a5f059e..3eebbd6 100644 --- a/src/gif.c +++ b/src/gif.c @@ -1257,7 +1257,7 @@ cleanup: } /* exported function documented in nsgif.h */ -void nsgif_destroy(nsgif *gif) +void nsgif_destroy(nsgif_t *gif) { if (gif == NULL) { return; @@ -1283,9 +1283,9 @@ void nsgif_destroy(nsgif *gif) } /* exported function documented in nsgif.h */ -nsgif_error nsgif_create(const nsgif_bitmap_cb_vt *bitmap_vt, nsgif **gif_out) +nsgif_error nsgif_create(const nsgif_bitmap_cb_vt *bitmap_vt, nsgif_t **gif_out) { - nsgif *gif; + nsgif_t *gif; gif = calloc(1, sizeof(*gif)); if (gif == NULL) { @@ -1389,7 +1389,7 @@ static nsgif_error nsgif__parse_logical_screen_descriptor( /* exported function documented in nsgif.h */ nsgif_error nsgif_data_scan( - nsgif *gif, + nsgif_t *gif, size_t size, const uint8_t *data) { @@ -1525,7 +1525,9 @@ nsgif_error nsgif_data_scan( return ret; } -static void nsgif__redraw_rect_extend(const nsgif_rect *frame, nsgif_rect *redraw) +static void nsgif__redraw_rect_extend( + const nsgif_rect_t *frame, + nsgif_rect_t *redraw) { if (redraw->x1 == 0 || redraw->y1 == 0) { *redraw = *frame; @@ -1546,7 +1548,7 @@ static void nsgif__redraw_rect_extend(const nsgif_rect *frame, nsgif_rect *redra } static uint32_t nsgif__frame_next( - nsgif *gif, + nsgif_t *gif, bool partial, uint32_t frame) { @@ -1563,7 +1565,7 @@ static uint32_t nsgif__frame_next( } static nsgif_error nsgif__next_displayable_frame( - nsgif *gif, + nsgif_t *gif, uint32_t *frame, uint32_t *delay) { @@ -1595,7 +1597,7 @@ static inline bool nsgif__animation_complete(int count, int max) } nsgif_error nsgif_reset( - nsgif *gif) + nsgif_t *gif) { gif->info.loop_count = 0; gif->frame = NSGIF_FRAME_INVALID; @@ -1605,13 +1607,13 @@ nsgif_error nsgif_reset( /* exported function documented in nsgif.h */ nsgif_error nsgif_frame_prepare( - nsgif *gif, - nsgif_rect *area, + nsgif_t *gif, + nsgif_rect_t *area, uint32_t *delay_cs, uint32_t *frame_new) { nsgif_error ret; - nsgif_rect rect = { + nsgif_rect_t rect = { .x1 = 0, .y1 = 0, }; @@ -1666,7 +1668,7 @@ nsgif_error nsgif_frame_prepare( /* exported function documented in nsgif.h */ nsgif_error nsgif_frame_decode( - nsgif *gif, + nsgif_t *gif, uint32_t frame, nsgif_bitmap_t **bitmap) { @@ -1702,14 +1704,14 @@ nsgif_error nsgif_frame_decode( } /* exported function documented in nsgif.h */ -const nsgif_info_t *nsgif_get_info(const nsgif *gif) +const nsgif_info_t *nsgif_get_info(const nsgif_t *gif) { return &gif->info; } /* exported function documented in nsgif.h */ const nsgif_frame_info_t *nsgif_get_frame_info( - const nsgif *gif, + const nsgif_t *gif, uint32_t frame) { if (frame > gif->info.frame_count) { diff --git a/test/nsgif.c b/test/nsgif.c index 23fd3f3..50b75b0 100644 --- a/test/nsgif.c +++ b/test/nsgif.c @@ -156,7 +156,7 @@ static void print_gif_frame_info(const nsgif_frame_info_t *info) fprintf(stdout, " h: %"PRIu32"\n", info->rect.y1 - info->rect.y0); } -static void decode(FILE* ppm, const char *name, nsgif *gif) +static void decode(FILE* ppm, const char *name, nsgif_t *gif) { nsgif_error err; uint32_t frame_prev = 0; @@ -185,7 +185,7 @@ static void decode(FILE* ppm, const char *name, nsgif *gif) const uint8_t *image; uint32_t frame_new; uint32_t delay_cs; - nsgif_rect area; + nsgif_rect_t area; err = nsgif_frame_prepare(gif, &area, &delay_cs, &frame_new); @@ -244,8 +244,8 @@ int main(int argc, char *argv[]) .destroy = bitmap_destroy, .get_buffer = bitmap_get_buffer, }; - nsgif *gif; size_t size; + nsgif_t *gif; uint8_t *data; nsgif_error err; FILE *ppm = NULL; -- cgit v1.2.1