mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[libpng16] Consistently use memset(), memcpy(), and memcmp() instead of the
png_memset(), png_memcpy(), and png_memcmp() macros.
This commit is contained in:
parent
e2098ba085
commit
dbb7e19fda
4
ANNOUNCE
4
ANNOUNCE
@ -431,12 +431,12 @@ Version 1.6.0beta27 [August 10, 2012]
|
||||
and cause it not to fail at the comparison step if libpng lacks support
|
||||
for writing chunks that it reads from the input (currently only implemented
|
||||
for compressed text chunks).
|
||||
Consistently use png_memset(), png_memcpy(), and png_memcmp(), except in
|
||||
pngtest.c and example.c where these macros are not visible.
|
||||
Make all three "make check" test programs work without READ or WRITE support.
|
||||
Now "make check" will succeed even if libpng is compiled with -DPNG_NO_READ
|
||||
or -DPNG_NO_WRITE. The tests performed are reduced, but the basic reading
|
||||
and writing of a PNG file is always tested by one or more of the tests.
|
||||
Consistently use memset(), memcpy(), and memcmp() instead of the png_memset(),
|
||||
png_memcpy(), and png_memcmp() macros.
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
|
4
CHANGES
4
CHANGES
@ -4182,12 +4182,12 @@ Version 1.6.0beta27 [August 10, 2012]
|
||||
and cause it not to fail at the comparison step if libpng lacks support
|
||||
for writing chunks that it reads from the input (currently only implemented
|
||||
for compressed text chunks).
|
||||
Consistently use png_memset(), png_memcpy(), and png_memcmp(), except in
|
||||
pngtest.c and example.c where these macros are not visible.
|
||||
Make all three "make check" test programs work without READ or WRITE support.
|
||||
Now "make check" will succeed even if libpng is compiled with -DPNG_NO_READ
|
||||
or -DPNG_NO_WRITE. The tests performed are reduced, but the basic reading
|
||||
and writing of a PNG file is always tested by one or more of the tests.
|
||||
Consistently use memset(), memcpy(), and memcmp() instead of the png_memset(),
|
||||
png_memcpy(), and png_memcmp() macros.
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
|
12
png.c
12
png.c
@ -62,7 +62,7 @@ png_sig_cmp(png_const_bytep sig, png_size_t start, png_size_t num_to_check)
|
||||
if (start + num_to_check > 8)
|
||||
num_to_check = 8 - start;
|
||||
|
||||
return ((int)(png_memcmp(&sig[start], &png_signature[start], num_to_check)));
|
||||
return ((int)(memcmp(&sig[start], &png_signature[start], num_to_check)));
|
||||
}
|
||||
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
@ -232,7 +232,7 @@ png_create_png_struct,(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
* build enough context to allow the user provided memory allocator (if any)
|
||||
* to be called.
|
||||
*/
|
||||
png_memset(&create_struct, 0, (sizeof create_struct));
|
||||
memset(&create_struct, 0, (sizeof create_struct));
|
||||
|
||||
/* Added at libpng-1.2.6 */
|
||||
# ifdef PNG_USER_LIMITS_SUPPORTED
|
||||
@ -337,7 +337,7 @@ png_create_info_struct,(png_const_structrp png_ptr),PNG_ALLOCATED)
|
||||
(sizeof *info_ptr)));
|
||||
|
||||
if (info_ptr != NULL)
|
||||
png_memset(info_ptr, 0, (sizeof *info_ptr));
|
||||
memset(info_ptr, 0, (sizeof *info_ptr));
|
||||
|
||||
return info_ptr;
|
||||
}
|
||||
@ -374,7 +374,7 @@ png_destroy_info_struct(png_const_structrp png_ptr, png_infopp info_ptr_ptr)
|
||||
*info_ptr_ptr = NULL;
|
||||
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);
|
||||
png_memset(info_ptr, 0, (sizeof *info_ptr));
|
||||
memset(info_ptr, 0, (sizeof *info_ptr));
|
||||
png_free(png_ptr, info_ptr);
|
||||
}
|
||||
}
|
||||
@ -410,7 +410,7 @@ png_info_init_3,(png_infopp ptr_ptr, png_size_t png_info_struct_size),
|
||||
}
|
||||
|
||||
/* Set everything to 0 */
|
||||
png_memset(info_ptr, 0, (sizeof *info_ptr));
|
||||
memset(info_ptr, 0, (sizeof *info_ptr));
|
||||
}
|
||||
|
||||
/* The following API is not called internally */
|
||||
@ -822,7 +822,7 @@ png_handle_as_unknown(png_structrp png_ptr, png_const_bytep chunk_name)
|
||||
do /* num_chunk_list > 0, so at least one */
|
||||
{
|
||||
p -= 5;
|
||||
if (!png_memcmp(chunk_name, p, 4))
|
||||
if (!memcmp(chunk_name, p, 4))
|
||||
return p[4];
|
||||
}
|
||||
while (p > p_end);
|
||||
|
@ -517,7 +517,7 @@ png_fixed_error,(png_const_structrp png_ptr, png_const_charp name),PNG_NORETURN)
|
||||
# define fixed_message_ln ((sizeof fixed_message)-1)
|
||||
int iin;
|
||||
char msg[fixed_message_ln+PNG_MAX_ERROR_TEXT];
|
||||
png_memcpy(msg, fixed_message, fixed_message_ln);
|
||||
memcpy(msg, fixed_message, fixed_message_ln);
|
||||
iin = 0;
|
||||
if (name != NULL) while (iin < (PNG_MAX_ERROR_TEXT-1) && name[iin] != 0)
|
||||
{
|
||||
|
4
pngmem.c
4
pngmem.c
@ -30,7 +30,7 @@ png_destroy_png_struct(png_structrp png_ptr)
|
||||
* png_get_mem_ptr, so fake a temporary png_struct to support this.
|
||||
*/
|
||||
png_struct dummy_struct = *png_ptr;
|
||||
png_memset(png_ptr, 0, (sizeof *png_ptr));
|
||||
memset(png_ptr, 0, (sizeof *png_ptr));
|
||||
png_free(&dummy_struct, png_ptr);
|
||||
|
||||
# ifdef PNG_SETJMP_SUPPORTED
|
||||
@ -54,7 +54,7 @@ png_calloc,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
ret = png_malloc(png_ptr, size);
|
||||
|
||||
if (ret != NULL)
|
||||
png_memset(ret, 0, size);
|
||||
memset(ret, 0, size);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
12
pngpread.c
12
pngpread.c
@ -649,7 +649,7 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
|
||||
else
|
||||
save_size = png_ptr->save_buffer_size;
|
||||
|
||||
png_memcpy(ptr, png_ptr->save_buffer_ptr, save_size);
|
||||
memcpy(ptr, png_ptr->save_buffer_ptr, save_size);
|
||||
length -= save_size;
|
||||
ptr += save_size;
|
||||
png_ptr->buffer_size -= save_size;
|
||||
@ -666,7 +666,7 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
|
||||
else
|
||||
save_size = png_ptr->current_buffer_size;
|
||||
|
||||
png_memcpy(ptr, png_ptr->current_buffer_ptr, save_size);
|
||||
memcpy(ptr, png_ptr->current_buffer_ptr, save_size);
|
||||
png_ptr->buffer_size -= save_size;
|
||||
png_ptr->current_buffer_size -= save_size;
|
||||
png_ptr->current_buffer_ptr += save_size;
|
||||
@ -715,13 +715,13 @@ png_push_save_buffer(png_structrp png_ptr)
|
||||
png_error(png_ptr, "Insufficient memory for save_buffer");
|
||||
}
|
||||
|
||||
png_memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size);
|
||||
memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size);
|
||||
png_free(png_ptr, old_buffer);
|
||||
png_ptr->save_buffer_max = new_max;
|
||||
}
|
||||
if (png_ptr->current_buffer_size)
|
||||
{
|
||||
png_memcpy(png_ptr->save_buffer + png_ptr->save_buffer_size,
|
||||
memcpy(png_ptr->save_buffer + png_ptr->save_buffer_size,
|
||||
png_ptr->current_buffer_ptr, png_ptr->current_buffer_size);
|
||||
png_ptr->save_buffer_size += png_ptr->current_buffer_size;
|
||||
png_ptr->current_buffer_size = 0;
|
||||
@ -976,7 +976,7 @@ png_push_process_row(png_structrp png_ptr)
|
||||
* it may not be in the future, so this was changed just to copy the
|
||||
* interlaced row count:
|
||||
*/
|
||||
png_memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1);
|
||||
memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1);
|
||||
|
||||
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
|
||||
if (png_ptr->transformations)
|
||||
@ -1210,7 +1210,7 @@ png_read_push_finish_row(png_structrp png_ptr)
|
||||
if (png_ptr->interlaced)
|
||||
{
|
||||
png_ptr->row_number = 0;
|
||||
png_memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
|
||||
memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -988,7 +988,7 @@ PNG_INTERNAL_FUNCTION(void,png_write_start_row,(png_structrp png_ptr),PNG_EMPTY)
|
||||
|
||||
/* Combine a row of data, dealing with alpha, etc. if requested. 'row' is an
|
||||
* array of png_ptr->width pixels. If the image is not interlaced or this
|
||||
* is the final pass this just does a png_memcpy, otherwise the "display" flag
|
||||
* is the final pass this just does a memcpy, otherwise the "display" flag
|
||||
* is used to determine whether to copy pixels that are not in the current pass.
|
||||
*
|
||||
* Because 'png_do_read_interlace' (below) replicates pixels this allows this
|
||||
|
12
pngread.c
12
pngread.c
@ -474,7 +474,7 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||
* it may not be in the future, so this was changed just to copy the
|
||||
* interlaced count:
|
||||
*/
|
||||
png_memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1);
|
||||
memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1);
|
||||
|
||||
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
|
||||
@ -1169,7 +1169,7 @@ png_image_read_init(png_imagep image)
|
||||
/* And set the rest of the structure to NULL to ensure that the various
|
||||
* fields are consistent.
|
||||
*/
|
||||
png_memset(image, 0, (sizeof *image));
|
||||
memset(image, 0, (sizeof *image));
|
||||
image->version = PNG_IMAGE_VERSION;
|
||||
|
||||
if (png_ptr != NULL)
|
||||
@ -1183,7 +1183,7 @@ png_image_read_init(png_imagep image)
|
||||
|
||||
if (control != NULL)
|
||||
{
|
||||
png_memset(control, 0, (sizeof *control));
|
||||
memset(control, 0, (sizeof *control));
|
||||
|
||||
control->png_ptr = png_ptr;
|
||||
control->info_ptr = info_ptr;
|
||||
@ -1399,7 +1399,7 @@ png_image_memory_read(png_structp png_ptr, png_bytep out, png_size_t need)
|
||||
|
||||
if (memory != NULL && size >= need)
|
||||
{
|
||||
png_memcpy(out, memory, need);
|
||||
memcpy(out, memory, need);
|
||||
cp->memory = memory + need;
|
||||
cp->size = size - need;
|
||||
return;
|
||||
@ -2527,7 +2527,7 @@ png_image_read_colormap(png_voidp argument)
|
||||
* PNG_CMAP_RGB algorithm will use. If the two entries don't
|
||||
* match, add the new one and set this as the background index.
|
||||
*/
|
||||
if (png_memcmp((png_const_bytep)display->colormap +
|
||||
if (memcmp((png_const_bytep)display->colormap +
|
||||
sample_size * cmap_entries,
|
||||
(png_const_bytep)display->colormap +
|
||||
sample_size * PNG_RGB_INDEX(r,g,b),
|
||||
@ -3907,7 +3907,7 @@ png_image_finish_read(png_imagep image, png_const_colorp background,
|
||||
int result;
|
||||
png_image_read_control display;
|
||||
|
||||
png_memset(&display, 0, (sizeof display));
|
||||
memset(&display, 0, (sizeof display));
|
||||
display.image = image;
|
||||
display.buffer = buffer;
|
||||
display.row_stride = row_stride;
|
||||
|
@ -364,7 +364,7 @@ png_set_alpha_mode_fixed(png_structrp png_ptr, int mode,
|
||||
if (compose)
|
||||
{
|
||||
/* And obtain alpha pre-multiplication by composing on black: */
|
||||
png_memset(&png_ptr->background, 0, (sizeof png_ptr->background));
|
||||
memset(&png_ptr->background, 0, (sizeof png_ptr->background));
|
||||
png_ptr->background_gamma = png_ptr->colorspace.gamma; /* just in case */
|
||||
png_ptr->background_gamma_type = PNG_BACKGROUND_GAMMA_FILE;
|
||||
png_ptr->transformations &= ~PNG_BACKGROUND_EXPAND;
|
||||
@ -746,7 +746,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
||||
distance = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_entries *
|
||||
(sizeof (png_byte))));
|
||||
|
||||
png_memset(distance, 0xff, num_entries * (sizeof (png_byte)));
|
||||
memset(distance, 0xff, num_entries * (sizeof (png_byte)));
|
||||
|
||||
for (i = 0; i < num_palette; i++)
|
||||
{
|
||||
|
30
pngrutil.c
30
pngrutil.c
@ -463,7 +463,7 @@ png_inflate(png_structrp png_ptr, png_uint_32 owner, int finish,
|
||||
* inside it is possible to chunk the input to zlib and simply rely on
|
||||
* zlib to advance the 'next_in' pointer. This allows arbitrary
|
||||
* amounts of data to be passed through zlib at the unavoidable cost of
|
||||
* requiring a window save (png_memcpy of up to 32768 output bytes)
|
||||
* requiring a window save (memcpy of up to 32768 output bytes)
|
||||
* every ZLIB_IO_MAX input bytes.
|
||||
*/
|
||||
avail_in += png_ptr->zstream.avail_in; /* not consumed last time */
|
||||
@ -633,7 +633,7 @@ png_decompress_chunk(png_structrp png_ptr,
|
||||
text[prefix_size + *newlength] = 0;
|
||||
|
||||
if (prefix_size > 0)
|
||||
png_memcpy(text, png_ptr->read_buffer, prefix_size);
|
||||
memcpy(text, png_ptr->read_buffer, prefix_size);
|
||||
|
||||
{
|
||||
png_bytep old_ptr = png_ptr->read_buffer;
|
||||
@ -1438,7 +1438,7 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
|
||||
if (profile != NULL)
|
||||
{
|
||||
png_memcpy(profile, profile_header,
|
||||
memcpy(profile, profile_header,
|
||||
(sizeof profile_header));
|
||||
|
||||
size = 12 * tag_count;
|
||||
@ -1508,7 +1508,7 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
keyword_length+1));
|
||||
if (info_ptr->iccp_name != NULL)
|
||||
{
|
||||
png_memcpy(info_ptr->iccp_name, keyword,
|
||||
memcpy(info_ptr->iccp_name, keyword,
|
||||
keyword_length+1);
|
||||
info_ptr->iccp_proflen =
|
||||
profile_length;
|
||||
@ -2952,7 +2952,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
|
||||
/* end_mask is now the bits to *keep* from the destination row */
|
||||
}
|
||||
|
||||
/* For non-interlaced images this reduces to a png_memcpy(). A png_memcpy()
|
||||
/* For non-interlaced images this reduces to a memcpy(). A memcpy()
|
||||
* will also happen if interlacing isn't supported or if the application
|
||||
* does not call png_set_interlace_handling(). In the latter cases the
|
||||
* caller just gets a sequence of the unexpanded rows from each interlace
|
||||
@ -3253,9 +3253,9 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
|
||||
/* Check for double byte alignment and, if possible, use a
|
||||
* 16-bit copy. Don't attempt this for narrow images - ones that
|
||||
* are less than an interlace panel wide. Don't attempt it for
|
||||
* wide bytes_to_copy either - use the png_memcpy there.
|
||||
* wide bytes_to_copy either - use the memcpy there.
|
||||
*/
|
||||
if (bytes_to_copy < 16 /*else use png_memcpy*/ &&
|
||||
if (bytes_to_copy < 16 /*else use memcpy*/ &&
|
||||
png_isaligned(dp, png_uint_16) &&
|
||||
png_isaligned(sp, png_uint_16) &&
|
||||
bytes_to_copy % (sizeof (png_uint_16)) == 0 &&
|
||||
@ -3347,10 +3347,10 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
|
||||
}
|
||||
#endif /* PNG_ALIGN_ code */
|
||||
|
||||
/* The true default - use a png_memcpy: */
|
||||
/* The true default - use a memcpy: */
|
||||
for (;;)
|
||||
{
|
||||
png_memcpy(dp, sp, bytes_to_copy);
|
||||
memcpy(dp, sp, bytes_to_copy);
|
||||
|
||||
if (row_width <= bytes_to_jump)
|
||||
return;
|
||||
@ -3371,11 +3371,11 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
|
||||
else
|
||||
#endif
|
||||
|
||||
/* If here then the switch above wasn't used so just png_memcpy the whole row
|
||||
/* If here then the switch above wasn't used so just memcpy the whole row
|
||||
* from the temporary row buffer (notice that this overwrites the end of the
|
||||
* destination row if it is a partial byte.)
|
||||
*/
|
||||
png_memcpy(dp, sp, PNG_ROWBYTES(pixel_depth, row_width));
|
||||
memcpy(dp, sp, PNG_ROWBYTES(pixel_depth, row_width));
|
||||
|
||||
/* Restore the overwritten bits from the last byte if necessary. */
|
||||
if (end_ptr != NULL)
|
||||
@ -3604,11 +3604,11 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
png_byte v[8];
|
||||
int j;
|
||||
|
||||
png_memcpy(v, sp, pixel_bytes);
|
||||
memcpy(v, sp, pixel_bytes);
|
||||
|
||||
for (j = 0; j < jstop; j++)
|
||||
{
|
||||
png_memcpy(dp, v, pixel_bytes);
|
||||
memcpy(dp, v, pixel_bytes);
|
||||
dp -= pixel_bytes;
|
||||
}
|
||||
|
||||
@ -4082,7 +4082,7 @@ png_read_finish_row(png_structrp png_ptr)
|
||||
/* TO DO: don't do this if prev_row isn't needed (requires
|
||||
* read-ahead of the next row's filter byte.
|
||||
*/
|
||||
png_memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
|
||||
memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
|
||||
|
||||
do
|
||||
{
|
||||
@ -4380,7 +4380,7 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
||||
if (png_ptr->rowbytes > (PNG_SIZE_MAX - 1))
|
||||
png_error(png_ptr, "Row has too many bytes to allocate in memory");
|
||||
|
||||
png_memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
|
||||
memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
|
||||
|
||||
png_debug1(3, "width = %u,", png_ptr->width);
|
||||
png_debug1(3, "height = %u,", png_ptr->height);
|
||||
|
48
pngset.c
48
pngset.c
@ -327,7 +327,7 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
return;
|
||||
}
|
||||
|
||||
png_memcpy(info_ptr->pcal_purpose, purpose, length);
|
||||
memcpy(info_ptr->pcal_purpose, purpose, length);
|
||||
|
||||
png_debug(3, "storing X0, X1, type, and nparams in info");
|
||||
info_ptr->pcal_X0 = X0;
|
||||
@ -348,7 +348,7 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
return;
|
||||
}
|
||||
|
||||
png_memcpy(info_ptr->pcal_units, units, length);
|
||||
memcpy(info_ptr->pcal_units, units, length);
|
||||
|
||||
info_ptr->pcal_params = png_voidcast(png_charpp, png_malloc_warn(png_ptr,
|
||||
(png_size_t)((nparams + 1) * (sizeof (png_charp)))));
|
||||
@ -359,7 +359,7 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
return;
|
||||
}
|
||||
|
||||
png_memset(info_ptr->pcal_params, 0, (nparams + 1) * (sizeof (png_charp)));
|
||||
memset(info_ptr->pcal_params, 0, (nparams + 1) * (sizeof (png_charp)));
|
||||
|
||||
for (i = 0; i < nparams; i++)
|
||||
{
|
||||
@ -375,7 +375,7 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
return;
|
||||
}
|
||||
|
||||
png_memcpy(info_ptr->pcal_params[i], params[i], length);
|
||||
memcpy(info_ptr->pcal_params[i], params[i], length);
|
||||
}
|
||||
|
||||
info_ptr->valid |= PNG_INFO_pCAL;
|
||||
@ -424,7 +424,7 @@ png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
return;
|
||||
}
|
||||
|
||||
png_memcpy(info_ptr->scal_s_width, swidth, lengthw);
|
||||
memcpy(info_ptr->scal_s_width, swidth, lengthw);
|
||||
|
||||
++lengthh;
|
||||
|
||||
@ -442,7 +442,7 @@ png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
return;
|
||||
}
|
||||
|
||||
png_memcpy(info_ptr->scal_s_height, sheight, lengthh);
|
||||
memcpy(info_ptr->scal_s_height, sheight, lengthh);
|
||||
|
||||
info_ptr->valid |= PNG_INFO_sCAL;
|
||||
info_ptr->free_me |= PNG_FREE_SCAL;
|
||||
@ -562,7 +562,7 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
|
||||
png_ptr->palette = png_voidcast(png_colorp, png_calloc(png_ptr,
|
||||
PNG_MAX_PALETTE_LENGTH * (sizeof (png_color))));
|
||||
|
||||
png_memcpy(png_ptr->palette, palette, num_palette * (sizeof (png_color)));
|
||||
memcpy(png_ptr->palette, palette, num_palette * (sizeof (png_color)));
|
||||
info_ptr->palette = png_ptr->palette;
|
||||
info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette;
|
||||
|
||||
@ -669,7 +669,7 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
return;
|
||||
}
|
||||
|
||||
png_memcpy(new_iccp_name, name, length);
|
||||
memcpy(new_iccp_name, name, length);
|
||||
new_iccp_profile = png_voidcast(png_bytep,
|
||||
png_malloc_warn(png_ptr, proflen));
|
||||
|
||||
@ -681,7 +681,7 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
return;
|
||||
}
|
||||
|
||||
png_memcpy(new_iccp_profile, profile, proflen);
|
||||
memcpy(new_iccp_profile, profile, proflen);
|
||||
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, 0);
|
||||
|
||||
@ -743,7 +743,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
return(1);
|
||||
}
|
||||
|
||||
png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max_text *
|
||||
memcpy(info_ptr->text, old_text, (png_size_t)(old_max_text *
|
||||
(sizeof (png_text))));
|
||||
png_free(png_ptr, old_text);
|
||||
}
|
||||
@ -845,16 +845,16 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
(key_len + lang_len + lang_key_len + text_length + 4),
|
||||
textp->key);
|
||||
|
||||
png_memcpy(textp->key, text_ptr[i].key,(png_size_t)(key_len));
|
||||
memcpy(textp->key, text_ptr[i].key,(png_size_t)(key_len));
|
||||
*(textp->key + key_len) = '\0';
|
||||
|
||||
if (text_ptr[i].compression > 0)
|
||||
{
|
||||
textp->lang = textp->key + key_len + 1;
|
||||
png_memcpy(textp->lang, text_ptr[i].lang, lang_len);
|
||||
memcpy(textp->lang, text_ptr[i].lang, lang_len);
|
||||
*(textp->lang + lang_len) = '\0';
|
||||
textp->lang_key = textp->lang + lang_len + 1;
|
||||
png_memcpy(textp->lang_key, text_ptr[i].lang_key, lang_key_len);
|
||||
memcpy(textp->lang_key, text_ptr[i].lang_key, lang_key_len);
|
||||
*(textp->lang_key + lang_key_len) = '\0';
|
||||
textp->text = textp->lang_key + lang_key_len + 1;
|
||||
}
|
||||
@ -867,7 +867,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
}
|
||||
|
||||
if (text_length)
|
||||
png_memcpy(textp->text, text_ptr[i].text,
|
||||
memcpy(textp->text, text_ptr[i].text,
|
||||
(png_size_t)(text_length));
|
||||
|
||||
*(textp->text + text_length) = '\0';
|
||||
@ -946,7 +946,7 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,
|
||||
png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH));
|
||||
|
||||
if (num_trans > 0 && num_trans <= PNG_MAX_PALETTE_LENGTH)
|
||||
png_memcpy(info_ptr->trans_alpha, trans_alpha, (png_size_t)num_trans);
|
||||
memcpy(info_ptr->trans_alpha, trans_alpha, (png_size_t)num_trans);
|
||||
}
|
||||
|
||||
if (trans_color != NULL)
|
||||
@ -1007,7 +1007,7 @@ png_set_sPLT(png_const_structrp png_ptr,
|
||||
return;
|
||||
}
|
||||
|
||||
png_memcpy(np, info_ptr->splt_palettes,
|
||||
memcpy(np, info_ptr->splt_palettes,
|
||||
info_ptr->splt_palettes_num * (sizeof (png_sPLT_t)));
|
||||
|
||||
png_free(png_ptr, info_ptr->splt_palettes);
|
||||
@ -1026,7 +1026,7 @@ png_set_sPLT(png_const_structrp png_ptr,
|
||||
* NULL, otherwise libpng will crash later on while trying to free the
|
||||
* uninitialized pointers.
|
||||
*/
|
||||
png_memset(to, 0, (sizeof *to));
|
||||
memset(to, 0, (sizeof *to));
|
||||
|
||||
if (from->name == NULL || from->entries == NULL)
|
||||
continue;
|
||||
@ -1041,7 +1041,7 @@ png_set_sPLT(png_const_structrp png_ptr,
|
||||
continue;
|
||||
}
|
||||
|
||||
png_memcpy(to->name, from->name, length);
|
||||
memcpy(to->name, from->name, length);
|
||||
to->entries = png_voidcast(png_sPLT_entryp, png_malloc_warn(png_ptr,
|
||||
from->nentries * (sizeof (png_sPLT_entry))));
|
||||
|
||||
@ -1053,7 +1053,7 @@ png_set_sPLT(png_const_structrp png_ptr,
|
||||
continue;
|
||||
}
|
||||
|
||||
png_memcpy(to->entries, from->entries,
|
||||
memcpy(to->entries, from->entries,
|
||||
from->nentries * (sizeof (png_sPLT_entry)));
|
||||
|
||||
to->nentries = from->nentries;
|
||||
@ -1089,7 +1089,7 @@ png_set_unknown_chunks(png_const_structrp png_ptr,
|
||||
return;
|
||||
}
|
||||
|
||||
png_memcpy(np, info_ptr->unknown_chunks,
|
||||
memcpy(np, info_ptr->unknown_chunks,
|
||||
(png_size_t)info_ptr->unknown_chunks_num *
|
||||
(sizeof (png_unknown_chunk)));
|
||||
|
||||
@ -1101,7 +1101,7 @@ png_set_unknown_chunks(png_const_structrp png_ptr,
|
||||
png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i;
|
||||
png_const_unknown_chunkp from = unknowns + i;
|
||||
|
||||
png_memcpy(to->name, from->name, (sizeof from->name));
|
||||
memcpy(to->name, from->name, (sizeof from->name));
|
||||
to->name[(sizeof to->name)-1] = '\0';
|
||||
to->size = from->size;
|
||||
|
||||
@ -1124,7 +1124,7 @@ png_set_unknown_chunks(png_const_structrp png_ptr,
|
||||
}
|
||||
|
||||
else
|
||||
png_memcpy(to->data, from->data, from->size);
|
||||
memcpy(to->data, from->data, from->size);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1228,12 +1228,12 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
|
||||
|
||||
if (png_ptr->chunk_list != NULL)
|
||||
{
|
||||
png_memcpy(new_list, png_ptr->chunk_list, 5*old_num_chunks);
|
||||
memcpy(new_list, png_ptr->chunk_list, 5*old_num_chunks);
|
||||
png_free(png_ptr, png_ptr->chunk_list);
|
||||
png_ptr->chunk_list=NULL;
|
||||
}
|
||||
|
||||
png_memcpy(new_list + 5*old_num_chunks, chunk_list,
|
||||
memcpy(new_list + 5*old_num_chunks, chunk_list,
|
||||
5*(unsigned int)num_chunks);
|
||||
|
||||
for (p = new_list + 5*old_num_chunks + 4, i = 0; i<num_chunks; i++, p += 5)
|
||||
|
10
pngwrite.c
10
pngwrite.c
@ -762,7 +762,7 @@ png_write_row(png_structrp png_ptr, png_const_bytep row)
|
||||
png_debug1(3, "row_info->rowbytes = %lu", (unsigned long)row_info.rowbytes);
|
||||
|
||||
/* Copy user's row into buffer, leaving room for filter byte. */
|
||||
png_memcpy(png_ptr->row_buf + 1, row, row_info.rowbytes);
|
||||
memcpy(png_ptr->row_buf + 1, row, row_info.rowbytes);
|
||||
|
||||
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
/* Handle interlacing */
|
||||
@ -1590,7 +1590,7 @@ png_image_write_init(png_imagep image)
|
||||
|
||||
if (control != NULL)
|
||||
{
|
||||
png_memset(control, 0, (sizeof *control));
|
||||
memset(control, 0, (sizeof *control));
|
||||
|
||||
control->png_ptr = png_ptr;
|
||||
control->info_ptr = info_ptr;
|
||||
@ -1907,8 +1907,8 @@ png_image_set_PLTE(png_image_write_control *display)
|
||||
png_color palette[256];
|
||||
png_byte tRNS[256];
|
||||
|
||||
png_memset(tRNS, 255, (sizeof tRNS));
|
||||
png_memset(palette, 0, (sizeof palette));
|
||||
memset(tRNS, 255, (sizeof tRNS));
|
||||
memset(palette, 0, (sizeof palette));
|
||||
|
||||
for (i=num_trans=0; i<entries; ++i)
|
||||
{
|
||||
@ -2239,7 +2239,7 @@ png_image_write_to_stdio(png_imagep image, FILE *file, int convert_to_8bit,
|
||||
*/
|
||||
image->opaque->png_ptr->io_ptr = file;
|
||||
|
||||
png_memset(&display, 0, (sizeof display));
|
||||
memset(&display, 0, (sizeof display));
|
||||
display.image = image;
|
||||
display.buffer = buffer;
|
||||
display.row_stride = row_stride;
|
||||
|
@ -1886,8 +1886,8 @@ png_write_sCAL_s(png_structrp png_ptr, int unit, png_const_charp width,
|
||||
}
|
||||
|
||||
buf[0] = (png_byte)unit;
|
||||
png_memcpy(buf + 1, width, wlen + 1); /* Append the '\0' here */
|
||||
png_memcpy(buf + wlen + 2, height, hlen); /* Do NOT append the '\0' here */
|
||||
memcpy(buf + 1, width, wlen + 1); /* Append the '\0' here */
|
||||
memcpy(buf + wlen + 2, height, hlen); /* Do NOT append the '\0' here */
|
||||
|
||||
png_debug1(3, "sCAL total length = %u", (unsigned int)total_len);
|
||||
png_write_complete_chunk(png_ptr, png_sCAL, buf, total_len);
|
||||
@ -2122,7 +2122,7 @@ png_write_finish_row(png_structrp png_ptr)
|
||||
if (png_ptr->pass < 7)
|
||||
{
|
||||
if (png_ptr->prev_row != NULL)
|
||||
png_memset(png_ptr->prev_row, 0,
|
||||
memset(png_ptr->prev_row, 0,
|
||||
(png_size_t)(PNG_ROWBYTES(png_ptr->usr_channels*
|
||||
png_ptr->usr_bit_depth, png_ptr->width)) + 1);
|
||||
|
||||
@ -2297,7 +2297,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
|
||||
|
||||
/* Move the pixel */
|
||||
if (dp != sp)
|
||||
png_memcpy(dp, sp, pixel_bytes);
|
||||
memcpy(dp, sp, pixel_bytes);
|
||||
|
||||
/* Next pixel */
|
||||
dp += pixel_bytes;
|
||||
|
Loading…
x
Reference in New Issue
Block a user