mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[libpng16] Replace the remaining uses of png_size_t with size_t
In v1.6.0, size_t became a required type. It should be used consistently. To maintain backwards compatibility, png_size_t is still maintained in deprecated form.
This commit is contained in:
@@ -950,7 +950,7 @@ write_png(const char **name, FILE *fp, int color_type, int bit_depth,
|
||||
int passes = 1;
|
||||
# endif /* !WRITE_INTERLACING */
|
||||
int pass;
|
||||
png_size_t rowbytes = png_get_rowbytes(png_ptr, info_ptr);
|
||||
size_t rowbytes = png_get_rowbytes(png_ptr, info_ptr);
|
||||
|
||||
row = malloc(rowbytes);
|
||||
|
||||
@@ -1094,7 +1094,7 @@ load_file(png_const_charp name, png_bytepp result)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static png_size_t
|
||||
static size_t
|
||||
load_fake(png_charp param, png_bytepp profile)
|
||||
{
|
||||
char *endptr = NULL;
|
||||
@@ -1164,7 +1164,7 @@ insert_iCCP(png_structp png_ptr, png_infop info_ptr, int nparams,
|
||||
{
|
||||
case '<':
|
||||
{
|
||||
png_size_t filelen = load_file(params[1]+1, &profile);
|
||||
size_t filelen = load_file(params[1]+1, &profile);
|
||||
if (filelen > 0xfffffffc) /* Maximum profile length */
|
||||
{
|
||||
fprintf(stderr, "%s: file too long (%lu) for an ICC profile\n",
|
||||
@@ -1179,7 +1179,7 @@ insert_iCCP(png_structp png_ptr, png_infop info_ptr, int nparams,
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
{
|
||||
png_size_t fake_len = load_fake(params[1], &profile);
|
||||
size_t fake_len = load_fake(params[1], &profile);
|
||||
|
||||
if (fake_len > 0) /* else a simple parameter */
|
||||
{
|
||||
@@ -1274,7 +1274,7 @@ set_text(png_structp png_ptr, png_infop info_ptr, png_textp text,
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
{
|
||||
png_bytep data = NULL;
|
||||
png_size_t fake_len = load_fake(param, &data);
|
||||
size_t fake_len = load_fake(param, &data);
|
||||
|
||||
if (fake_len > 0) /* else a simple parameter */
|
||||
{
|
||||
|
||||
@@ -551,7 +551,7 @@ struct display
|
||||
png_structp original_pp; /* used on the original read */
|
||||
png_infop original_ip; /* set by the original read */
|
||||
|
||||
png_size_t original_rowbytes; /* of the original rows: */
|
||||
size_t original_rowbytes; /* of the original rows: */
|
||||
png_bytepp original_rows; /* from the original read */
|
||||
|
||||
/* Original chunks valid */
|
||||
@@ -807,7 +807,7 @@ display_cache_file(struct display *dp, const char *filename)
|
||||
|
||||
static void
|
||||
buffer_read(struct display *dp, struct buffer *bp, png_bytep data,
|
||||
png_size_t size)
|
||||
size_t size)
|
||||
{
|
||||
struct buffer_list *last = bp->current;
|
||||
size_t read_count = bp->read_count;
|
||||
@@ -855,7 +855,7 @@ buffer_read(struct display *dp, struct buffer *bp, png_bytep data,
|
||||
}
|
||||
|
||||
static void PNGCBAPI
|
||||
read_function(png_structp pp, png_bytep data, png_size_t size)
|
||||
read_function(png_structp pp, png_bytep data, size_t size)
|
||||
{
|
||||
buffer_read(get_dp(pp), get_buffer(pp), data, size);
|
||||
}
|
||||
@@ -1267,7 +1267,7 @@ compare_read(struct display *dp, int applied_transforms)
|
||||
#ifdef PNG_WRITE_PNG_SUPPORTED
|
||||
static void
|
||||
buffer_write(struct display *dp, struct buffer *buffer, png_bytep data,
|
||||
png_size_t size)
|
||||
size_t size)
|
||||
/* Generic write function used both from the write callback provided to
|
||||
* libpng and from the generic read code.
|
||||
*/
|
||||
@@ -1311,7 +1311,7 @@ buffer_write(struct display *dp, struct buffer *buffer, png_bytep data,
|
||||
}
|
||||
|
||||
static void PNGCBAPI
|
||||
write_function(png_structp pp, png_bytep data, png_size_t size)
|
||||
write_function(png_structp pp, png_bytep data, size_t size)
|
||||
{
|
||||
buffer_write(get_dp(pp), get_buffer(pp), data, size);
|
||||
}
|
||||
|
||||
@@ -578,11 +578,11 @@ typedef struct
|
||||
int stride_extra;
|
||||
FILE *input_file;
|
||||
png_voidp input_memory;
|
||||
png_size_t input_memory_size;
|
||||
size_t input_memory_size;
|
||||
png_bytep buffer;
|
||||
ptrdiff_t stride;
|
||||
png_size_t bufsize;
|
||||
png_size_t allocsize;
|
||||
size_t bufsize;
|
||||
size_t allocsize;
|
||||
char tmpfile_name[32];
|
||||
png_uint_16 colormap[256*4];
|
||||
}
|
||||
@@ -665,7 +665,7 @@ static void initimage(Image *image, png_uint_32 opts, const char *file_name,
|
||||
static void
|
||||
allocbuffer(Image *image)
|
||||
{
|
||||
png_size_t size = PNG_IMAGE_BUFFER_SIZE(image->image, image->stride);
|
||||
size_t size = PNG_IMAGE_BUFFER_SIZE(image->image, image->stride);
|
||||
|
||||
if (size+32 > image->bufsize)
|
||||
{
|
||||
|
||||
@@ -711,7 +711,7 @@ typedef struct png_store_file
|
||||
unsigned int IDAT_bits; /* Number of bits in IDAT size */
|
||||
png_uint_32 IDAT_size; /* Total size of IDAT data */
|
||||
png_uint_32 id; /* must be correct (see FILEID) */
|
||||
png_size_t datacount; /* In this (the last) buffer */
|
||||
size_t datacount; /* In this (the last) buffer */
|
||||
png_store_buffer data; /* Last buffer in file */
|
||||
int npalette; /* Number of entries in palette */
|
||||
store_palette_entry* palette; /* May be NULL */
|
||||
@@ -777,10 +777,10 @@ typedef struct png_store
|
||||
png_infop piread;
|
||||
png_store_file* current; /* Set when reading */
|
||||
png_store_buffer* next; /* Set when reading */
|
||||
png_size_t readpos; /* Position in *next */
|
||||
size_t readpos; /* Position in *next */
|
||||
png_byte* image; /* Buffer for reading interlaced images */
|
||||
png_size_t cb_image; /* Size of this buffer */
|
||||
png_size_t cb_row; /* Row size of the image(s) */
|
||||
size_t cb_image; /* Size of this buffer */
|
||||
size_t cb_row; /* Row size of the image(s) */
|
||||
uLong IDAT_crc;
|
||||
png_uint_32 IDAT_len; /* Used when re-chunking IDAT chunks */
|
||||
png_uint_32 IDAT_pos; /* Used when re-chunking IDAT chunks */
|
||||
@@ -791,7 +791,7 @@ typedef struct png_store
|
||||
png_store_file* saved;
|
||||
png_structp pwrite; /* Used when writing a new file */
|
||||
png_infop piwrite;
|
||||
png_size_t writepos; /* Position in .new */
|
||||
size_t writepos; /* Position in .new */
|
||||
char wname[FILE_NAME_SIZE];
|
||||
png_store_buffer new; /* The end of the new PNG file being written. */
|
||||
store_pool write_memory_pool;
|
||||
@@ -1125,7 +1125,7 @@ static png_bytep
|
||||
store_image_row(const png_store* ps, png_const_structp pp, int nImage,
|
||||
png_uint_32 y)
|
||||
{
|
||||
png_size_t coffset = (nImage * ps->image_h + y) * (ps->cb_row + 5) + 2;
|
||||
size_t coffset = (nImage * ps->image_h + y) * (ps->cb_row + 5) + 2;
|
||||
|
||||
if (ps->image == NULL)
|
||||
png_error(pp, "no allocated image");
|
||||
@@ -1160,9 +1160,9 @@ store_image_free(png_store *ps, png_const_structp pp)
|
||||
|
||||
static void
|
||||
store_ensure_image(png_store *ps, png_const_structp pp, int nImages,
|
||||
png_size_t cbRow, png_uint_32 cRows)
|
||||
size_t cbRow, png_uint_32 cRows)
|
||||
{
|
||||
png_size_t cb = nImages * cRows * (cbRow + 5);
|
||||
size_t cb = nImages * cRows * (cbRow + 5);
|
||||
|
||||
if (ps->cb_image < cb)
|
||||
{
|
||||
@@ -1234,7 +1234,7 @@ store_image_check(const png_store* ps, png_const_structp pp, int iImage)
|
||||
png_error(pp, "image overwrite");
|
||||
else
|
||||
{
|
||||
png_size_t cbRow = ps->cb_row;
|
||||
size_t cbRow = ps->cb_row;
|
||||
png_uint_32 rows = ps->image_h;
|
||||
|
||||
image += iImage * (cbRow+5) * ps->image_h;
|
||||
@@ -1278,7 +1278,7 @@ valid_chunktype(png_uint_32 chunktype)
|
||||
}
|
||||
|
||||
static void PNGCBAPI
|
||||
store_write(png_structp ppIn, png_bytep pb, png_size_t st)
|
||||
store_write(png_structp ppIn, png_bytep pb, size_t st)
|
||||
{
|
||||
png_const_structp pp = ppIn;
|
||||
png_store *ps = voidcast(png_store*, png_get_io_ptr(pp));
|
||||
@@ -1346,13 +1346,13 @@ store_write(png_structp ppIn, png_bytep pb, png_size_t st)
|
||||
|
||||
else /* chunkpos >= 8 */
|
||||
{
|
||||
png_size_t cb = st;
|
||||
size_t cb = st;
|
||||
|
||||
if (cb > STORE_BUFFER_SIZE - writepos)
|
||||
cb = STORE_BUFFER_SIZE - writepos;
|
||||
|
||||
if (cb > chunklen - chunkpos/* bytes left in chunk*/)
|
||||
cb = (png_size_t)/*SAFE*/(chunklen - chunkpos);
|
||||
cb = (size_t)/*SAFE*/(chunklen - chunkpos);
|
||||
|
||||
memcpy(ps->new.buffer + writepos, pb, cb);
|
||||
chunkpos += (png_uint_32)/*SAFE*/cb;
|
||||
@@ -1440,7 +1440,7 @@ store_read_buffer_next(png_store *ps)
|
||||
* during progressive read, where the io_ptr is set internally by libpng.
|
||||
*/
|
||||
static void
|
||||
store_read_imp(png_store *ps, png_bytep pb, png_size_t st)
|
||||
store_read_imp(png_store *ps, png_bytep pb, size_t st)
|
||||
{
|
||||
if (ps->current == NULL || ps->next == NULL)
|
||||
png_error(ps->pread, "store state damaged");
|
||||
@@ -1463,14 +1463,13 @@ store_read_imp(png_store *ps, png_bytep pb, png_size_t st)
|
||||
}
|
||||
}
|
||||
|
||||
static png_size_t
|
||||
store_read_chunk(png_store *ps, png_bytep pb, const png_size_t max,
|
||||
const png_size_t min)
|
||||
static size_t
|
||||
store_read_chunk(png_store *ps, png_bytep pb, size_t max, size_t min)
|
||||
{
|
||||
png_uint_32 chunklen = ps->chunklen;
|
||||
png_uint_32 chunktype = ps->chunktype;
|
||||
png_uint_32 chunkpos = ps->chunkpos;
|
||||
png_size_t st = max;
|
||||
size_t st = max;
|
||||
|
||||
if (st > 0) do
|
||||
{
|
||||
@@ -1601,8 +1600,8 @@ store_read_chunk(png_store *ps, png_bytep pb, const png_size_t max,
|
||||
|
||||
store_read_imp(ps, pb, avail);
|
||||
ps->IDAT_crc = crc32(ps->IDAT_crc, pb, avail);
|
||||
pb += (png_size_t)/*SAFE*/avail;
|
||||
st -= (png_size_t)/*SAFE*/avail;
|
||||
pb += (size_t)/*SAFE*/avail;
|
||||
st -= (size_t)/*SAFE*/avail;
|
||||
chunkpos += (png_uint_32)/*SAFE*/avail;
|
||||
IDAT_size -= (png_uint_32)/*SAFE*/avail;
|
||||
IDAT_pos += (png_uint_32)/*SAFE*/avail;
|
||||
@@ -1669,10 +1668,10 @@ store_read_chunk(png_store *ps, png_bytep pb, const png_size_t max,
|
||||
|
||||
else /* Return chunk bytes, including the CRC */
|
||||
{
|
||||
png_size_t avail = st;
|
||||
size_t avail = st;
|
||||
|
||||
if (avail > chunklen - chunkpos)
|
||||
avail = (png_size_t)/*SAFE*/(chunklen - chunkpos);
|
||||
avail = (size_t)/*SAFE*/(chunklen - chunkpos);
|
||||
|
||||
store_read_imp(ps, pb, avail);
|
||||
pb += avail;
|
||||
@@ -1698,7 +1697,7 @@ store_read_chunk(png_store *ps, png_bytep pb, const png_size_t max,
|
||||
}
|
||||
|
||||
static void PNGCBAPI
|
||||
store_read(png_structp ppIn, png_bytep pb, png_size_t st)
|
||||
store_read(png_structp ppIn, png_bytep pb, size_t st)
|
||||
{
|
||||
png_const_structp pp = ppIn;
|
||||
png_store *ps = voidcast(png_store*, png_get_io_ptr(pp));
|
||||
@@ -1724,7 +1723,7 @@ store_progressive_read(png_store *ps, png_structp pp, png_infop pi)
|
||||
while (store_read_buffer_avail(ps) > 0)
|
||||
{
|
||||
static png_uint_32 noise = 2;
|
||||
png_size_t cb;
|
||||
size_t cb;
|
||||
png_byte buffer[512];
|
||||
|
||||
/* Generate 15 more bits of stuff: */
|
||||
@@ -2991,7 +2990,7 @@ modifier_setbuffer(png_modifier *pm)
|
||||
* png_struct.
|
||||
*/
|
||||
static void
|
||||
modifier_read_imp(png_modifier *pm, png_bytep pb, png_size_t st)
|
||||
modifier_read_imp(png_modifier *pm, png_bytep pb, size_t st)
|
||||
{
|
||||
while (st > 0)
|
||||
{
|
||||
@@ -3137,7 +3136,7 @@ modifier_read_imp(png_modifier *pm, png_bytep pb, png_size_t st)
|
||||
*/
|
||||
if (len+12 <= sizeof pm->buffer)
|
||||
{
|
||||
png_size_t s = len+12-pm->buffer_count;
|
||||
size_t s = len+12-pm->buffer_count;
|
||||
store_read_chunk(&pm->this, pm->buffer+pm->buffer_count, s, s);
|
||||
pm->buffer_count = len+12;
|
||||
|
||||
@@ -3196,7 +3195,7 @@ modifier_read_imp(png_modifier *pm, png_bytep pb, png_size_t st)
|
||||
|
||||
/* The callback: */
|
||||
static void PNGCBAPI
|
||||
modifier_read(png_structp ppIn, png_bytep pb, png_size_t st)
|
||||
modifier_read(png_structp ppIn, png_bytep pb, size_t st)
|
||||
{
|
||||
png_const_structp pp = ppIn;
|
||||
png_modifier *pm = voidcast(png_modifier*, png_get_io_ptr(pp));
|
||||
@@ -3226,7 +3225,7 @@ modifier_progressive_read(png_modifier *pm, png_structp pp, png_infop pi)
|
||||
for (;;)
|
||||
{
|
||||
static png_uint_32 noise = 1;
|
||||
png_size_t cb, cbAvail;
|
||||
size_t cb, cbAvail;
|
||||
png_byte buffer[512];
|
||||
|
||||
/* Generate 15 more bits of stuff: */
|
||||
|
||||
@@ -60,7 +60,7 @@ read_png(FILE *fp)
|
||||
png_read_info(png_ptr, info_ptr);
|
||||
|
||||
{
|
||||
png_size_t rowbytes = png_get_rowbytes(png_ptr, info_ptr);
|
||||
size_t rowbytes = png_get_rowbytes(png_ptr, info_ptr);
|
||||
|
||||
/* Failure to initialize these is harmless */
|
||||
row = malloc(rowbytes);
|
||||
|
||||
@@ -108,7 +108,7 @@ int validation_ascii_to_fp(int count, int argc, char **argv)
|
||||
|
||||
do
|
||||
{
|
||||
png_size_t index;
|
||||
size_t index;
|
||||
int state, failed = 0;
|
||||
char buffer[64];
|
||||
|
||||
@@ -329,7 +329,7 @@ static int check_one_character(checkfp_command *co, checkfp_control c, int ch)
|
||||
{
|
||||
/* Test this character (ch) to ensure the parser does the correct thing.
|
||||
*/
|
||||
png_size_t index = 0;
|
||||
size_t index = 0;
|
||||
const char test = (char)ch;
|
||||
const int number_is_valid = png_check_fp_number(&test, 1, &c.state, &index);
|
||||
const int character_accepted = (index == 1);
|
||||
|
||||
@@ -65,7 +65,7 @@ typedef struct
|
||||
} io_data;
|
||||
|
||||
static PNG_CALLBACK(void, read_and_copy,
|
||||
(png_structp png_ptr, png_bytep buffer, png_size_t cb))
|
||||
(png_structp png_ptr, png_bytep buffer, size_t cb))
|
||||
{
|
||||
io_data *io = (io_data*)png_get_io_ptr(png_ptr);
|
||||
|
||||
@@ -100,7 +100,7 @@ static void read_by_row(png_structp png_ptr, png_infop info_ptr,
|
||||
png_read_info(png_ptr, info_ptr);
|
||||
|
||||
{
|
||||
png_size_t rowbytes = png_get_rowbytes(png_ptr, info_ptr);
|
||||
size_t rowbytes = png_get_rowbytes(png_ptr, info_ptr);
|
||||
|
||||
row = voidcast(png_bytep,malloc(rowbytes));
|
||||
display = voidcast(png_bytep,malloc(rowbytes));
|
||||
|
||||
@@ -68,7 +68,7 @@ struct PngObjectHandler {
|
||||
}
|
||||
};
|
||||
|
||||
void user_read_data(png_structp png_ptr, png_bytep data, png_size_t length) {
|
||||
void user_read_data(png_structp png_ptr, png_bytep data, size_t length) {
|
||||
BufState* buf_state = static_cast<BufState*>(png_get_io_ptr(png_ptr));
|
||||
if (length > buf_state->bytes_left) {
|
||||
png_error(png_ptr, "read error");
|
||||
|
||||
@@ -1725,7 +1725,7 @@ display_start_read(struct display *dp, const char *filename)
|
||||
}
|
||||
|
||||
static void PNGCBAPI
|
||||
read_function(png_structp pp, png_bytep data, png_size_t size)
|
||||
read_function(png_structp pp, png_bytep data, size_t size)
|
||||
{
|
||||
struct display *dp = get_dp(pp);
|
||||
|
||||
@@ -1881,7 +1881,7 @@ display_start_write(struct display *dp, const char *filename)
|
||||
}
|
||||
|
||||
static void PNGCBAPI
|
||||
write_function(png_structp pp, png_bytep data, png_size_t size)
|
||||
write_function(png_structp pp, png_bytep data, size_t size)
|
||||
{
|
||||
struct display *dp = get_dp(pp);
|
||||
|
||||
|
||||
@@ -410,15 +410,14 @@ BOOL PngSaveImage (PTSTR pstrFileName, png_byte *pDiData,
|
||||
#ifndef PNG_STDIO_SUPPORTED
|
||||
|
||||
static void
|
||||
png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
png_read_data(png_structp png_ptr, png_bytep data, size_t length)
|
||||
{
|
||||
png_size_t check;
|
||||
size_t check;
|
||||
|
||||
/* fread() returns 0 on error, so it is OK to store this in a png_size_t
|
||||
/* fread() returns 0 on error, so it is OK to store this in a size_t
|
||||
* instead of an int, which is what fread() actually returns.
|
||||
*/
|
||||
check = (png_size_t)fread(data, (png_size_t)1, length,
|
||||
(FILE *)png_ptr->io_ptr);
|
||||
check = fread(data, 1, length, (FILE *)png_ptr->io_ptr);
|
||||
|
||||
if (check != length)
|
||||
{
|
||||
@@ -427,7 +426,7 @@ png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
}
|
||||
|
||||
static void
|
||||
png_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
png_write_data(png_structp png_ptr, png_bytep data, size_t length)
|
||||
{
|
||||
png_uint_32 check;
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@ BOOL PngSaveImage (PTSTR pstrFileName, png_byte *pDiData,
|
||||
int iWidth, int iHeight, png_color BkgColor);
|
||||
|
||||
#ifndef PNG_STDIO_SUPPORTED
|
||||
static void png_read_data(png_structp png_ptr, png_bytep data, png_size_t length);
|
||||
static void png_write_data(png_structp png_ptr, png_bytep data, png_size_t length);
|
||||
static void png_read_data(png_structp png_ptr, png_bytep data, size_t length);
|
||||
static void png_write_data(png_structp png_ptr, png_bytep data, size_t length);
|
||||
static void png_flush(png_structp png_ptr);
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user