chore: Clean up the spurious uses of sizeof(png_byte); fix the manual

By definition, `sizeof(png_byte)` is 1.

Remove all the occurences of `sizeof(png_byte)` from the code, and fix
a related typo in the libpng manual.

Also update the main .editorconfig file to reflect the fixing expected
by a FIXME note.
This commit is contained in:
Cosmin Truta 2024-02-15 21:53:24 +02:00
parent 4191872d0d
commit 0fa3c0f698
4 changed files with 12 additions and 16 deletions

View File

@ -16,8 +16,7 @@ indent_style = space
[*.[chS]] [*.[chS]]
indent_style = space indent_style = space
max_doc_length = 80 max_doc_length = 80
max_line_length = 81 max_line_length = 80
# FIXME: max_line_length should be 80
[*.dfa] [*.dfa]
indent_style = space indent_style = space

View File

@ -1178,11 +1178,11 @@ where row_pointers is an array of pointers to the pixel data for each row:
If you know your image size and pixel size ahead of time, you can allocate If you know your image size and pixel size ahead of time, you can allocate
row_pointers prior to calling png_read_png() with row_pointers prior to calling png_read_png() with
if (height > PNG_UINT_32_MAX/(sizeof (png_byte))) if (height > PNG_UINT_32_MAX / (sizeof (png_bytep)))
png_error(png_ptr, png_error(png_ptr,
"Image is too tall to process in memory"); "Image is too tall to process in memory");
if (width > PNG_UINT_32_MAX/pixel_size) if (width > PNG_UINT_32_MAX / pixel_size)
png_error(png_ptr, png_error(png_ptr,
"Image is too wide to process in memory"); "Image is too wide to process in memory");

View File

@ -1697,11 +1697,11 @@ where row_pointers is an array of pointers to the pixel data for each row:
If you know your image size and pixel size ahead of time, you can allocate If you know your image size and pixel size ahead of time, you can allocate
row_pointers prior to calling png_read_png() with row_pointers prior to calling png_read_png() with
if (height > PNG_UINT_32_MAX/(sizeof (png_byte))) if (height > PNG_UINT_32_MAX / (sizeof (png_bytep)))
png_error(png_ptr, png_error(png_ptr,
"Image is too tall to process in memory"); "Image is too tall to process in memory");
if (width > PNG_UINT_32_MAX/pixel_size) if (width > PNG_UINT_32_MAX / pixel_size)
png_error(png_ptr, png_error(png_ptr,
"Image is too wide to process in memory"); "Image is too wide to process in memory");

View File

@ -440,7 +440,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
int i; int i;
png_ptr->quantize_index = (png_bytep)png_malloc(png_ptr, png_ptr->quantize_index = (png_bytep)png_malloc(png_ptr,
(png_alloc_size_t)((png_uint_32)num_palette * (sizeof (png_byte)))); (png_alloc_size_t)num_palette);
for (i = 0; i < num_palette; i++) for (i = 0; i < num_palette; i++)
png_ptr->quantize_index[i] = (png_byte)i; png_ptr->quantize_index[i] = (png_byte)i;
} }
@ -457,7 +457,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
/* Initialize an array to sort colors */ /* Initialize an array to sort colors */
png_ptr->quantize_sort = (png_bytep)png_malloc(png_ptr, png_ptr->quantize_sort = (png_bytep)png_malloc(png_ptr,
(png_alloc_size_t)((png_uint_32)num_palette * (sizeof (png_byte)))); (png_alloc_size_t)num_palette);
/* Initialize the quantize_sort array */ /* Initialize the quantize_sort array */
for (i = 0; i < num_palette; i++) for (i = 0; i < num_palette; i++)
@ -591,11 +591,9 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
/* Initialize palette index arrays */ /* Initialize palette index arrays */
png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr, png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr,
(png_alloc_size_t)((png_uint_32)num_palette * (png_alloc_size_t)num_palette);
(sizeof (png_byte))));
png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr, png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr,
(png_alloc_size_t)((png_uint_32)num_palette * (png_alloc_size_t)num_palette);
(sizeof (png_byte))));
/* Initialize the sort array */ /* Initialize the sort array */
for (i = 0; i < num_palette; i++) for (i = 0; i < num_palette; i++)
@ -760,12 +758,11 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
size_t num_entries = ((size_t)1 << total_bits); size_t num_entries = ((size_t)1 << total_bits);
png_ptr->palette_lookup = (png_bytep)png_calloc(png_ptr, png_ptr->palette_lookup = (png_bytep)png_calloc(png_ptr,
(png_alloc_size_t)(num_entries * (sizeof (png_byte)))); (png_alloc_size_t)(num_entries));
distance = (png_bytep)png_malloc(png_ptr, (png_alloc_size_t)(num_entries * distance = (png_bytep)png_malloc(png_ptr, (png_alloc_size_t)num_entries);
(sizeof (png_byte))));
memset(distance, 0xff, num_entries * (sizeof (png_byte))); memset(distance, 0xff, num_entries);
for (i = 0; i < num_palette; i++) for (i = 0; i < num_palette; i++)
{ {