From 4f67e40898c5508d114e0c7e57cd089c87c53a89 Mon Sep 17 00:00:00 2001 From: John Bowler Date: Wed, 28 Dec 2011 08:43:37 -0600 Subject: [PATCH] [libpng16] Add 'const' to png_structrp arguments of png_set_*() APIs. Because these APIs store to the png_info they can take a png_const_structrp now that the error routines also accept one of these. --- png.c | 12 +++--- png.h | 116 ++++++++++++++++++++++++++------------------------- pngget.c | 7 ++-- pngpriv.h | 10 ++--- pngread.c | 12 ++---- pngset.c | 117 +++++++++++++++++++++++++++------------------------- pngstruct.h | 4 -- 7 files changed, 140 insertions(+), 138 deletions(-) diff --git a/png.c b/png.c index 53733509c..c2e15f7c5 100644 --- a/png.c +++ b/png.c @@ -762,13 +762,13 @@ png_get_copyright(png_const_structrp png_ptr) #else # ifdef __STDC__ return PNG_STRING_NEWLINE \ - "libpng version 1.6.0beta04 - December 24, 2011" PNG_STRING_NEWLINE \ + "libpng version 1.6.0beta04 - December 28, 2011" PNG_STRING_NEWLINE \ "Copyright (c) 1998-2011 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \ "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \ "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \ PNG_STRING_NEWLINE; # else - return "libpng version 1.6.0beta04 - December 24, 2011\ + return "libpng version 1.6.0beta04 - December 28, 2011\ Copyright (c) 1998-2011 Glenn Randers-Pehrson\ Copyright (c) 1996-1997 Andreas Dilger\ Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc."; @@ -884,7 +884,7 @@ png_access_version_number(void) # ifdef PNG_CHECK_cHRM_SUPPORTED int /* PRIVATE */ -png_check_cHRM_fixed(png_structrp png_ptr, +png_check_cHRM_fixed(png_const_structrp png_ptr, png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x, png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y, png_fixed_point blue_x, png_fixed_point blue_y) @@ -1608,7 +1608,7 @@ png_pow10(int power) * precision. */ void /* PRIVATE */ -png_ascii_from_fp(png_structrp png_ptr, png_charp ascii, png_size_t size, +png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size, double fp, unsigned int precision) { /* We use standard functions from math.h, but not printf because @@ -1922,8 +1922,8 @@ png_ascii_from_fp(png_structrp png_ptr, png_charp ascii, png_size_t size, /* Function to format a fixed point value in ASCII. */ void /* PRIVATE */ -png_ascii_from_fixed(png_structrp png_ptr, png_charp ascii, png_size_t size, - png_fixed_point fp) +png_ascii_from_fixed(png_const_structrp png_ptr, png_charp ascii, + png_size_t size, png_fixed_point fp) { /* Require space for 10 decimal digits, a decimal point, a minus sign and a * trailing \0, 13 characters: diff --git a/png.h b/png.h index ad96b3f1c..1b977678c 100644 --- a/png.h +++ b/png.h @@ -1,7 +1,7 @@ /* png.h - header file for PNG reference library * - * libpng version 1.6.0beta04 - December 24, 2011 + * libpng version 1.6.0beta04 - December 28, 2011 * Copyright (c) 1998-2011 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -11,7 +11,7 @@ * Authors and maintainers: * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat * libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger - * libpng versions 0.97, January 1998, through 1.6.0beta04 - December 24, 2011: Glenn + * libpng versions 0.97, January 1998, through 1.6.0beta04 - December 28, 2011: Glenn * See also "Contributing Authors", below. * * Note about libpng version numbers: @@ -198,7 +198,7 @@ * * This code is released under the libpng license. * - * libpng versions 1.2.6, August 15, 2004, through 1.6.0beta04, December 24, 2011, are + * libpng versions 1.2.6, August 15, 2004, through 1.6.0beta04, December 28, 2011, are * Copyright (c) 2004, 2006-2011 Glenn Randers-Pehrson, and are * distributed according to the same disclaimer and license as libpng-1.2.5 * with the following individual added to the list of Contributing Authors: @@ -310,7 +310,7 @@ * Y2K compliance in libpng: * ========================= * - * December 24, 2011 + * December 28, 2011 * * Since the PNG Development group is an ad-hoc body, we can't make * an official declaration. @@ -376,7 +376,7 @@ /* Version information for png.h - this should match the version in png.c */ #define PNG_LIBPNG_VER_STRING "1.6.0beta04" #define PNG_HEADER_VERSION_STRING \ - " libpng version 1.6.0beta04 - December 24, 2011\n" + " libpng version 1.6.0beta04 - December 28, 2011\n" #define PNG_LIBPNG_VER_SONUM 16 #define PNG_LIBPNG_VER_DLLNUM 16 @@ -2000,8 +2000,8 @@ PNG_EXPORT(112, png_bytepp, png_get_rows, (png_const_structrp png_ptr, /* Set row_pointers, which is an array of pointers to scanlines for use * by png_write_png(). */ -PNG_EXPORT(113, void, png_set_rows, (png_structrp png_ptr, png_inforp info_ptr, - png_bytepp row_pointers)); +PNG_EXPORT(113, void, png_set_rows, (png_const_structrp png_ptr, + png_inforp info_ptr, png_bytepp row_pointers)); #endif /* Returns number of color channels in image. */ @@ -2065,7 +2065,7 @@ PNG_EXPORT(129, png_int_32, png_get_y_offset_microns, /* Returns pointer to signature string read from PNG header */ PNG_EXPORT(130, png_const_bytep, png_get_signature, (png_const_structrp png_ptr, - png_inforp info_ptr)); + png_const_inforp info_ptr)); #ifdef PNG_bKGD_SUPPORTED PNG_EXPORT(131, png_uint_32, png_get_bKGD, (png_const_structrp png_ptr, @@ -2073,8 +2073,8 @@ PNG_EXPORT(131, png_uint_32, png_get_bKGD, (png_const_structrp png_ptr, #endif #ifdef PNG_bKGD_SUPPORTED -PNG_EXPORT(132, void, png_set_bKGD, (png_structrp png_ptr, png_inforp info_ptr, - png_const_color_16p background)); +PNG_EXPORT(132, void, png_set_bKGD, (png_const_structrp png_ptr, + png_inforp info_ptr, png_const_color_16p background)); #endif #ifdef PNG_cHRM_SUPPORTED @@ -2104,20 +2104,21 @@ PNG_FIXED_EXPORT(231, png_uint_32, png_get_cHRM_XYZ_fixed, #endif #ifdef PNG_cHRM_SUPPORTED -PNG_FP_EXPORT(135, void, png_set_cHRM, (png_structrp png_ptr, png_inforp info_ptr, +PNG_FP_EXPORT(135, void, png_set_cHRM, (png_const_structrp png_ptr, + png_inforp info_ptr, double white_x, double white_y, double red_x, double red_y, double green_x, double green_y, double blue_x, double blue_y)); -PNG_FP_EXPORT(232, void, png_set_cHRM_XYZ, (png_structrp png_ptr, +PNG_FP_EXPORT(232, void, png_set_cHRM_XYZ, (png_const_structrp png_ptr, png_inforp info_ptr, double red_X, double red_Y, double red_Z, double green_X, double green_Y, double green_Z, double blue_X, double blue_Y, double blue_Z)); -PNG_FIXED_EXPORT(136, void, png_set_cHRM_fixed, (png_structrp png_ptr, +PNG_FIXED_EXPORT(136, void, png_set_cHRM_fixed, (png_const_structrp png_ptr, png_inforp info_ptr, png_fixed_point int_white_x, png_fixed_point int_white_y, png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, png_fixed_point int_blue_y)); -PNG_FIXED_EXPORT(233, void, png_set_cHRM_XYZ_fixed, (png_structrp png_ptr, +PNG_FIXED_EXPORT(233, void, png_set_cHRM_XYZ_fixed, (png_const_structrp png_ptr, png_inforp info_ptr, png_fixed_point int_red_X, png_fixed_point int_red_Y, png_fixed_point int_red_Z, png_fixed_point int_green_X, png_fixed_point int_green_Y, png_fixed_point int_green_Z, @@ -2134,9 +2135,9 @@ PNG_FIXED_EXPORT(138, png_uint_32, png_get_gAMA_fixed, #endif #ifdef PNG_gAMA_SUPPORTED -PNG_FP_EXPORT(139, void, png_set_gAMA, (png_structrp png_ptr, +PNG_FP_EXPORT(139, void, png_set_gAMA, (png_const_structrp png_ptr, png_inforp info_ptr, double file_gamma)); -PNG_FIXED_EXPORT(140, void, png_set_gAMA_fixed, (png_structrp png_ptr, +PNG_FIXED_EXPORT(140, void, png_set_gAMA_fixed, (png_const_structrp png_ptr, png_inforp info_ptr, png_fixed_point int_file_gamma)); #endif @@ -2146,18 +2147,19 @@ PNG_EXPORT(141, png_uint_32, png_get_hIST, (png_const_structrp png_ptr, #endif #ifdef PNG_hIST_SUPPORTED -PNG_EXPORT(142, void, png_set_hIST, (png_structrp png_ptr, png_inforp info_ptr, - png_const_uint_16p hist)); +PNG_EXPORT(142, void, png_set_hIST, (png_const_structrp png_ptr, + png_inforp info_ptr, png_const_uint_16p hist)); #endif PNG_EXPORT(143, png_uint_32, png_get_IHDR, (png_const_structrp png_ptr, - png_inforp info_ptr, png_uint_32 *width, png_uint_32 *height, + png_const_inforp info_ptr, png_uint_32 *width, png_uint_32 *height, int *bit_depth, int *color_type, int *interlace_method, int *compression_method, int *filter_method)); -PNG_EXPORT(144, void, png_set_IHDR, (png_structrp png_ptr, png_inforp info_ptr, - png_uint_32 width, png_uint_32 height, int bit_depth, int color_type, - int interlace_method, int compression_method, int filter_method)); +PNG_EXPORT(144, void, png_set_IHDR, (png_const_structrp png_ptr, + png_inforp info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, + int color_type, int interlace_method, int compression_method, + int filter_method)); #ifdef PNG_oFFs_SUPPORTED PNG_EXPORT(145, png_uint_32, png_get_oFFs, (png_const_structrp png_ptr, @@ -2166,8 +2168,9 @@ PNG_EXPORT(145, png_uint_32, png_get_oFFs, (png_const_structrp png_ptr, #endif #ifdef PNG_oFFs_SUPPORTED -PNG_EXPORT(146, void, png_set_oFFs, (png_structrp png_ptr, png_inforp info_ptr, - png_int_32 offset_x, png_int_32 offset_y, int unit_type)); +PNG_EXPORT(146, void, png_set_oFFs, (png_const_structrp png_ptr, + png_inforp info_ptr, png_int_32 offset_x, png_int_32 offset_y, + int unit_type)); #endif #ifdef PNG_pCAL_SUPPORTED @@ -2178,9 +2181,9 @@ PNG_EXPORT(147, png_uint_32, png_get_pCAL, (png_const_structrp png_ptr, #endif #ifdef PNG_pCAL_SUPPORTED -PNG_EXPORT(148, void, png_set_pCAL, (png_structrp png_ptr, png_inforp info_ptr, - png_const_charp purpose, png_int_32 X0, png_int_32 X1, int type, - int nparams, png_const_charp units, png_charpp params)); +PNG_EXPORT(148, void, png_set_pCAL, (png_const_structrp png_ptr, + png_inforp info_ptr, png_const_charp purpose, png_int_32 X0, png_int_32 X1, + int type, int nparams, png_const_charp units, png_charpp params)); #endif #ifdef PNG_pHYs_SUPPORTED @@ -2190,15 +2193,15 @@ PNG_EXPORT(149, png_uint_32, png_get_pHYs, (png_const_structrp png_ptr, #endif #ifdef PNG_pHYs_SUPPORTED -PNG_EXPORT(150, void, png_set_pHYs, (png_structrp png_ptr, png_inforp info_ptr, - png_uint_32 res_x, png_uint_32 res_y, int unit_type)); +PNG_EXPORT(150, void, png_set_pHYs, (png_const_structrp png_ptr, + png_inforp info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type)); #endif PNG_EXPORT(151, png_uint_32, png_get_PLTE, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_colorp *palette, int *num_palette)); -PNG_EXPORT(152, void, png_set_PLTE, (png_structrp png_ptr, png_inforp info_ptr, - png_const_colorp palette, int num_palette)); +PNG_EXPORT(152, void, png_set_PLTE, (png_structrp png_ptr, + png_inforp info_ptr, png_const_colorp palette, int num_palette)); #ifdef PNG_sBIT_SUPPORTED PNG_EXPORT(153, png_uint_32, png_get_sBIT, (png_const_structrp png_ptr, @@ -2206,8 +2209,8 @@ PNG_EXPORT(153, png_uint_32, png_get_sBIT, (png_const_structrp png_ptr, #endif #ifdef PNG_sBIT_SUPPORTED -PNG_EXPORT(154, void, png_set_sBIT, (png_structrp png_ptr, png_inforp info_ptr, - png_const_color_8p sig_bit)); +PNG_EXPORT(154, void, png_set_sBIT, (png_const_structrp png_ptr, + png_inforp info_ptr, png_const_color_8p sig_bit)); #endif #ifdef PNG_sRGB_SUPPORTED @@ -2216,9 +2219,9 @@ PNG_EXPORT(155, png_uint_32, png_get_sRGB, (png_const_structrp png_ptr, #endif #ifdef PNG_sRGB_SUPPORTED -PNG_EXPORT(156, void, png_set_sRGB, (png_structrp png_ptr, png_inforp info_ptr, - int srgb_intent)); -PNG_EXPORT(157, void, png_set_sRGB_gAMA_and_cHRM, (png_structrp png_ptr, +PNG_EXPORT(156, void, png_set_sRGB, (png_const_structrp png_ptr, + png_inforp info_ptr, int srgb_intent)); +PNG_EXPORT(157, void, png_set_sRGB_gAMA_and_cHRM, (png_const_structrp png_ptr, png_inforp info_ptr, int srgb_intent)); #endif @@ -2229,9 +2232,9 @@ PNG_EXPORT(158, png_uint_32, png_get_iCCP, (png_const_structrp png_ptr, #endif #ifdef PNG_iCCP_SUPPORTED -PNG_EXPORT(159, void, png_set_iCCP, (png_structrp png_ptr, png_inforp info_ptr, - png_const_charp name, int compression_type, png_const_bytep profile, - png_uint_32 proflen)); +PNG_EXPORT(159, void, png_set_iCCP, (png_const_structrp png_ptr, + png_inforp info_ptr, png_const_charp name, int compression_type, + png_const_bytep profile, png_uint_32 proflen)); #endif #ifdef PNG_sPLT_SUPPORTED @@ -2240,8 +2243,8 @@ PNG_EXPORT(160, png_uint_32, png_get_sPLT, (png_const_structrp png_ptr, #endif #ifdef PNG_sPLT_SUPPORTED -PNG_EXPORT(161, void, png_set_sPLT, (png_structrp png_ptr, png_inforp info_ptr, - png_const_sPLT_tp entries, int nentries)); +PNG_EXPORT(161, void, png_set_sPLT, (png_const_structrp png_ptr, + png_inforp info_ptr, png_const_sPLT_tp entries, int nentries)); #endif #ifdef PNG_TEXT_SUPPORTED @@ -2258,8 +2261,8 @@ PNG_EXPORT(162, png_uint_32, png_get_text, (png_const_structrp png_ptr, */ #ifdef PNG_TEXT_SUPPORTED -PNG_EXPORT(163, void, png_set_text, (png_structrp png_ptr, png_inforp info_ptr, - png_const_textp text_ptr, int num_text)); +PNG_EXPORT(163, void, png_set_text, (png_const_structrp png_ptr, + png_inforp info_ptr, png_const_textp text_ptr, int num_text)); #endif #ifdef PNG_tIME_SUPPORTED @@ -2268,8 +2271,8 @@ PNG_EXPORT(164, png_uint_32, png_get_tIME, (png_const_structrp png_ptr, #endif #ifdef PNG_tIME_SUPPORTED -PNG_EXPORT(165, void, png_set_tIME, (png_structrp png_ptr, png_inforp info_ptr, - png_const_timep mod_time)); +PNG_EXPORT(165, void, png_set_tIME, (png_const_structrp png_ptr, + png_inforp info_ptr, png_const_timep mod_time)); #endif #ifdef PNG_tRNS_SUPPORTED @@ -2279,8 +2282,8 @@ PNG_EXPORT(166, png_uint_32, png_get_tRNS, (png_const_structrp png_ptr, #endif #ifdef PNG_tRNS_SUPPORTED -PNG_EXPORT(167, void, png_set_tRNS, (png_structrp png_ptr, png_inforp info_ptr, - png_const_bytep trans_alpha, int num_trans, +PNG_EXPORT(167, void, png_set_tRNS, (png_structrp png_ptr, + png_inforp info_ptr, png_const_bytep trans_alpha, int num_trans, png_const_color_16p trans_color)); #endif @@ -2302,13 +2305,14 @@ PNG_EXPORT(169, png_uint_32, png_get_sCAL_s, (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit, png_charpp swidth, png_charpp sheight)); -PNG_FP_EXPORT(170, void, png_set_sCAL, (png_structrp png_ptr, png_inforp info_ptr, - int unit, double width, double height)); -PNG_FIXED_EXPORT(213, void, png_set_sCAL_fixed, (png_structrp png_ptr, +PNG_FP_EXPORT(170, void, png_set_sCAL, (png_const_structrp png_ptr, + png_inforp info_ptr, int unit, double width, double height)); +PNG_FIXED_EXPORT(213, void, png_set_sCAL_fixed, (png_const_structrp png_ptr, png_inforp info_ptr, int unit, png_fixed_point width, png_fixed_point height)); -PNG_EXPORT(171, void, png_set_sCAL_s, (png_structrp png_ptr, png_inforp info_ptr, - int unit, png_const_charp swidth, png_const_charp sheight)); +PNG_EXPORT(171, void, png_set_sCAL_s, (png_const_structrp png_ptr, + png_inforp info_ptr, int unit, + png_const_charp swidth, png_const_charp sheight)); #endif /* PNG_sCAL_SUPPORTED */ #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED @@ -2333,11 +2337,11 @@ PNG_EXPORT(173, int, png_handle_as_unknown, (png_structrp png_ptr, png_const_bytep chunk_name)); #endif #ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED -PNG_EXPORT(174, void, png_set_unknown_chunks, (png_structrp png_ptr, +PNG_EXPORT(174, void, png_set_unknown_chunks, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns)); -PNG_EXPORT(175, void, png_set_unknown_chunk_location, (png_structrp png_ptr, - png_inforp info_ptr, int chunk, int location)); +PNG_EXPORT(175, void, png_set_unknown_chunk_location, + (png_const_structrp png_ptr, png_inforp info_ptr, int chunk, int location)); PNG_EXPORT(176, int, png_get_unknown_chunks, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_unknown_chunkpp entries)); #endif @@ -2348,7 +2352,7 @@ PNG_EXPORT(176, int, png_get_unknown_chunks, (png_const_structrp png_ptr, */ PNG_EXPORT(177, void, png_set_invalid, (png_const_structrp png_ptr, png_inforp info_ptr, int mask)); - + #ifdef PNG_INFO_IMAGE_SUPPORTED /* The "params" pointer is currently not used and is for future expansion. */ PNG_EXPORT(178, void, png_read_png, (png_structrp png_ptr, png_inforp info_ptr, diff --git a/pngget.c b/pngget.c index 288364333..4e1df5f30 100644 --- a/pngget.c +++ b/pngget.c @@ -432,7 +432,7 @@ png_get_channels(png_const_structrp png_ptr, png_const_inforp info_ptr) } png_const_bytep PNGAPI -png_get_signature(png_const_structrp png_ptr, png_inforp info_ptr) +png_get_signature(png_const_structrp png_ptr, png_const_inforp info_ptr) { if (png_ptr != NULL && info_ptr != NULL) return(info_ptr->signature); @@ -733,7 +733,7 @@ png_get_hIST(png_const_structrp png_ptr, png_const_inforp info_ptr, #endif png_uint_32 PNGAPI -png_get_IHDR(png_const_structrp png_ptr, png_inforp info_ptr, +png_get_IHDR(png_const_structrp png_ptr, png_const_inforp info_ptr, png_uint_32 *width, png_uint_32 *height, int *bit_depth, int *color_type, int *interlace_type, int *compression_type, int *filter_type) @@ -975,7 +975,8 @@ png_get_text(png_const_structrp png_ptr, png_const_inforp info_ptr, #ifdef PNG_tIME_SUPPORTED png_uint_32 PNGAPI -png_get_tIME(png_const_structrp png_ptr, png_inforp info_ptr, png_timep *mod_time) +png_get_tIME(png_const_structrp png_ptr, png_inforp info_ptr, + png_timep *mod_time) { png_debug1(1, "in %s retrieval function", "tIME"); diff --git a/pngpriv.h b/pngpriv.h index f5ae898f5..8d7fd0c52 100644 --- a/pngpriv.h +++ b/pngpriv.h @@ -874,7 +874,7 @@ PNG_EXTERN void png_write_iTXt PNGARG((png_structrp png_ptr, #endif #ifdef PNG_TEXT_SUPPORTED /* Added at version 1.0.14 and 1.2.4 */ -PNG_EXTERN int png_set_text_2 PNGARG((png_structrp png_ptr, +PNG_EXTERN int png_set_text_2 PNGARG((png_const_structrp png_ptr, png_inforp info_ptr, png_const_textp text_ptr, int num_text)); #endif @@ -1316,7 +1316,7 @@ PNG_EXTERN void png_do_write_intrapixel PNGARG((png_row_infop row_info, /* Added at libpng version 1.4.0 */ #ifdef PNG_CHECK_cHRM_SUPPORTED -PNG_EXTERN int png_check_cHRM_fixed PNGARG((png_structrp png_ptr, +PNG_EXTERN int png_check_cHRM_fixed PNGARG((png_const_structrp png_ptr, png_fixed_point int_white_x, png_fixed_point int_white_y, png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, @@ -1452,12 +1452,12 @@ PNG_EXTERN void png_formatted_warning(png_const_structrp png_ptr, #define PNG_sCAL_MAX_DIGITS (PNG_sCAL_PRECISION+1/*.*/+1/*E*/+10/*exponent*/) #ifdef PNG_FLOATING_POINT_SUPPORTED -PNG_EXTERN void png_ascii_from_fp PNGARG((png_structrp png_ptr, png_charp ascii, - png_size_t size, double fp, unsigned int precision)); +PNG_EXTERN void png_ascii_from_fp PNGARG((png_const_structrp png_ptr, + png_charp ascii, png_size_t size, double fp, unsigned int precision)); #endif /* FLOATING_POINT */ #ifdef PNG_FIXED_POINT_SUPPORTED -PNG_EXTERN void png_ascii_from_fixed PNGARG((png_structrp png_ptr, +PNG_EXTERN void png_ascii_from_fixed PNGARG((png_const_structrp png_ptr, png_charp ascii, png_size_t size, png_fixed_point fp)); #endif /* FIXED_POINT */ #endif /* READ_sCAL */ diff --git a/pngread.c b/pngread.c index 3348a1b2a..174298be8 100644 --- a/pngread.c +++ b/pngread.c @@ -903,12 +903,6 @@ png_read_destroy(png_structrp png_ptr) png_ptr->free_me &= ~PNG_FREE_TRNS; #endif -#ifdef PNG_READ_hIST_SUPPORTED - if (png_ptr->free_me & PNG_FREE_HIST) - png_free(png_ptr, png_ptr->hist); - png_ptr->free_me &= ~PNG_FREE_HIST; -#endif - inflateEnd(&png_ptr->zstream); #ifdef PNG_PROGRESSIVE_READ_SUPPORTED @@ -1437,7 +1431,7 @@ png_image_read_composite(png_voidp argument) png_imagep image = display->image; png_structrp png_ptr = image->opaque->png_ptr; png_byte interlace_type = png_ptr->interlaced; - int passes = 0; + int passes; switch (interlace_type) { @@ -1450,6 +1444,7 @@ png_image_read_composite(png_voidp argument) break; default: + passes = 0; png_error(png_ptr, "unknown interlace type"); } @@ -1567,7 +1562,7 @@ png_image_read_background(png_voidp argument) png_byte interlace_type = png_ptr->interlaced; png_uint_32 height = image->height; png_uint_32 width = image->width; - int pass, passes = 0; + int pass, passes; /* Double check the convoluted logic below. We expect to get here with * libpng doing rgb to gray and gamma correction but background processing @@ -1599,6 +1594,7 @@ png_image_read_background(png_voidp argument) break; default: + passes = 0; png_error(png_ptr, "unknown interlace type"); } diff --git a/pngset.c b/pngset.c index e0c819691..e3849a324 100644 --- a/pngset.c +++ b/pngset.c @@ -22,7 +22,7 @@ #ifdef PNG_bKGD_SUPPORTED void PNGAPI -png_set_bKGD(png_structrp png_ptr, png_inforp info_ptr, +png_set_bKGD(png_const_structrp png_ptr, png_inforp info_ptr, png_const_color_16p background) { png_debug1(1, "in %s storage function", "bKGD"); @@ -37,7 +37,7 @@ png_set_bKGD(png_structrp png_ptr, png_inforp info_ptr, #ifdef PNG_cHRM_SUPPORTED void PNGFAPI -png_set_cHRM_fixed(png_structrp png_ptr, png_inforp info_ptr, +png_set_cHRM_fixed(png_const_structrp png_ptr, png_inforp info_ptr, png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x, png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y, png_fixed_point blue_x, png_fixed_point blue_y) @@ -65,7 +65,7 @@ png_set_cHRM_fixed(png_structrp png_ptr, png_inforp info_ptr, } void PNGFAPI -png_set_cHRM_XYZ_fixed(png_structrp png_ptr, png_inforp info_ptr, +png_set_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_inforp info_ptr, png_fixed_point int_red_X, png_fixed_point int_red_Y, png_fixed_point int_red_Z, png_fixed_point int_green_X, png_fixed_point int_green_Y, png_fixed_point int_green_Z, @@ -99,7 +99,7 @@ png_set_cHRM_XYZ_fixed(png_structrp png_ptr, png_inforp info_ptr, # ifdef PNG_FLOATING_POINT_SUPPORTED void PNGAPI -png_set_cHRM(png_structrp png_ptr, png_inforp info_ptr, +png_set_cHRM(png_const_structrp png_ptr, png_inforp info_ptr, double white_x, double white_y, double red_x, double red_y, double green_x, double green_y, double blue_x, double blue_y) { @@ -115,7 +115,7 @@ png_set_cHRM(png_structrp png_ptr, png_inforp info_ptr, } void PNGAPI -png_set_cHRM_XYZ(png_structrp png_ptr, png_inforp info_ptr, double red_X, +png_set_cHRM_XYZ(png_const_structrp png_ptr, png_inforp info_ptr, double red_X, double red_Y, double red_Z, double green_X, double green_Y, double green_Z, double blue_X, double blue_Y, double blue_Z) { @@ -136,8 +136,8 @@ png_set_cHRM_XYZ(png_structrp png_ptr, png_inforp info_ptr, double red_X, #ifdef PNG_gAMA_SUPPORTED void PNGFAPI -png_set_gAMA_fixed(png_structrp png_ptr, png_inforp info_ptr, png_fixed_point - file_gamma) +png_set_gAMA_fixed(png_const_structrp png_ptr, png_inforp info_ptr, + png_fixed_point file_gamma) { png_debug1(1, "in %s storage function", "gAMA"); @@ -164,7 +164,7 @@ png_set_gAMA_fixed(png_structrp png_ptr, png_inforp info_ptr, png_fixed_point # ifdef PNG_FLOATING_POINT_SUPPORTED void PNGAPI -png_set_gAMA(png_structrp png_ptr, png_inforp info_ptr, double file_gamma) +png_set_gAMA(png_const_structrp png_ptr, png_inforp info_ptr, double file_gamma) { png_set_gAMA_fixed(png_ptr, info_ptr, png_fixed(png_ptr, file_gamma, "png_set_gAMA")); @@ -174,7 +174,8 @@ png_set_gAMA(png_structrp png_ptr, png_inforp info_ptr, double file_gamma) #ifdef PNG_hIST_SUPPORTED void PNGAPI -png_set_hIST(png_structrp png_ptr, png_inforp info_ptr, png_const_uint_16p hist) +png_set_hIST(png_const_structrp png_ptr, png_inforp info_ptr, + png_const_uint_16p hist) { int i; @@ -197,26 +198,26 @@ png_set_hIST(png_structrp png_ptr, png_inforp info_ptr, png_const_uint_16p hist) /* Changed from info->num_palette to PNG_MAX_PALETTE_LENGTH in * version 1.2.1 */ - png_ptr->hist = (png_uint_16p)png_malloc_warn(png_ptr, - PNG_MAX_PALETTE_LENGTH * png_sizeof(png_uint_16)); + info_ptr->hist = png_voidcast(png_uint_16p, png_malloc_warn(png_ptr, + PNG_MAX_PALETTE_LENGTH * png_sizeof(png_uint_16))); - if (png_ptr->hist == NULL) + if (info_ptr->hist == NULL) { png_warning(png_ptr, "Insufficient memory for hIST chunk data"); return; } - for (i = 0; i < info_ptr->num_palette; i++) - png_ptr->hist[i] = hist[i]; - - info_ptr->hist = png_ptr->hist; - info_ptr->valid |= PNG_INFO_hIST; info_ptr->free_me |= PNG_FREE_HIST; + + for (i = 0; i < info_ptr->num_palette; i++) + info_ptr->hist[i] = hist[i]; + + info_ptr->valid |= PNG_INFO_hIST; } #endif void PNGAPI -png_set_IHDR(png_structrp png_ptr, png_inforp info_ptr, +png_set_IHDR(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, int color_type, int interlace_type, int compression_type, int filter_type) @@ -266,7 +267,7 @@ png_set_IHDR(png_structrp png_ptr, png_inforp info_ptr, #ifdef PNG_oFFs_SUPPORTED void PNGAPI -png_set_oFFs(png_structrp png_ptr, png_inforp info_ptr, +png_set_oFFs(png_const_structrp png_ptr, png_inforp info_ptr, png_int_32 offset_x, png_int_32 offset_y, int unit_type) { png_debug1(1, "in %s storage function", "oFFs"); @@ -283,7 +284,7 @@ png_set_oFFs(png_structrp png_ptr, png_inforp info_ptr, #ifdef PNG_pCAL_SUPPORTED void PNGAPI -png_set_pCAL(png_structrp png_ptr, png_inforp info_ptr, +png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr, png_const_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams, png_const_charp units, png_charpp params) { @@ -375,7 +376,7 @@ png_set_pCAL(png_structrp png_ptr, png_inforp info_ptr, #ifdef PNG_sCAL_SUPPORTED void PNGAPI -png_set_sCAL_s(png_structrp png_ptr, png_inforp info_ptr, +png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr, int unit, png_const_charp swidth, png_const_charp sheight) { png_size_t lengthw = 0, lengthh = 0; @@ -438,8 +439,8 @@ png_set_sCAL_s(png_structrp png_ptr, png_inforp info_ptr, # ifdef PNG_FLOATING_POINT_SUPPORTED void PNGAPI -png_set_sCAL(png_structrp png_ptr, png_inforp info_ptr, int unit, double width, - double height) +png_set_sCAL(png_const_structrp png_ptr, png_inforp info_ptr, int unit, + double width, double height) { png_debug1(1, "in %s storage function", "sCAL"); @@ -468,7 +469,7 @@ png_set_sCAL(png_structrp png_ptr, png_inforp info_ptr, int unit, double width, # ifdef PNG_FIXED_POINT_SUPPORTED void PNGAPI -png_set_sCAL_fixed(png_structrp png_ptr, png_inforp info_ptr, int unit, +png_set_sCAL_fixed(png_const_structrp png_ptr, png_inforp info_ptr, int unit, png_fixed_point width, png_fixed_point height) { png_debug1(1, "in %s storage function", "sCAL"); @@ -497,7 +498,7 @@ png_set_sCAL_fixed(png_structrp png_ptr, png_inforp info_ptr, int unit, #ifdef PNG_pHYs_SUPPORTED void PNGAPI -png_set_pHYs(png_structrp png_ptr, png_inforp info_ptr, +png_set_pHYs(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type) { png_debug1(1, "in %s storage function", "pHYs"); @@ -537,6 +538,9 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr, /* It may not actually be necessary to set png_ptr->palette here; * we do it for backward compatibility with the way the png_handle_tRNS * function used to do the allocation. + * + * 1.6.0: the above statement appears to be incorrect; something has to set + * the palette inside png_struct on read. */ png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0); @@ -558,7 +562,7 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr, #ifdef PNG_sBIT_SUPPORTED void PNGAPI -png_set_sBIT(png_structrp png_ptr, png_inforp info_ptr, +png_set_sBIT(png_const_structrp png_ptr, png_inforp info_ptr, png_const_color_8p sig_bit) { png_debug1(1, "in %s storage function", "sBIT"); @@ -573,7 +577,7 @@ png_set_sBIT(png_structrp png_ptr, png_inforp info_ptr, #ifdef PNG_sRGB_SUPPORTED void PNGAPI -png_set_sRGB(png_structrp png_ptr, png_inforp info_ptr, int srgb_intent) +png_set_sRGB(png_const_structrp png_ptr, png_inforp info_ptr, int srgb_intent) { png_debug1(1, "in %s storage function", "sRGB"); @@ -585,7 +589,7 @@ png_set_sRGB(png_structrp png_ptr, png_inforp info_ptr, int srgb_intent) } void PNGAPI -png_set_sRGB_gAMA_and_cHRM(png_structrp png_ptr, png_inforp info_ptr, +png_set_sRGB_gAMA_and_cHRM(png_const_structrp png_ptr, png_inforp info_ptr, int srgb_intent) { png_debug1(1, "in %s storage function", "sRGB_gAMA_and_cHRM"); @@ -614,7 +618,7 @@ png_set_sRGB_gAMA_and_cHRM(png_structrp png_ptr, png_inforp info_ptr, #ifdef PNG_iCCP_SUPPORTED void PNGAPI -png_set_iCCP(png_structrp png_ptr, png_inforp info_ptr, +png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr, png_const_charp name, int compression_type, png_const_bytep profile, png_uint_32 proflen) { @@ -665,8 +669,8 @@ png_set_iCCP(png_structrp png_ptr, png_inforp info_ptr, #ifdef PNG_TEXT_SUPPORTED void PNGAPI -png_set_text(png_structrp png_ptr, png_inforp info_ptr, png_const_textp text_ptr, - int num_text) +png_set_text(png_const_structrp png_ptr, png_inforp info_ptr, + png_const_textp text_ptr, int num_text) { int ret; ret = png_set_text_2(png_ptr, info_ptr, text_ptr, num_text); @@ -676,7 +680,7 @@ png_set_text(png_structrp png_ptr, png_inforp info_ptr, png_const_textp text_ptr } int /* PRIVATE */ -png_set_text_2(png_structrp png_ptr, png_inforp info_ptr, +png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr, png_const_textp text_ptr, int num_text) { int i; @@ -856,7 +860,8 @@ png_set_text_2(png_structrp png_ptr, png_inforp info_ptr, #ifdef PNG_tIME_SUPPORTED void PNGAPI -png_set_tIME(png_structrp png_ptr, png_inforp info_ptr, png_const_timep mod_time) +png_set_tIME(png_const_structrp png_ptr, png_inforp info_ptr, + png_const_timep mod_time) { png_debug1(1, "in %s storage function", "tIME"); @@ -893,13 +898,17 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr, /* It may not actually be necessary to set png_ptr->trans_alpha here; * we do it for backward compatibility with the way the png_handle_tRNS * function used to do the allocation. + * + * 1.6.0: The above statement is incorrect; png_handle_tRNS effectively + * relies on png_set_tRNS storing the information in png_struct + * (otherwise it won't be there for the code in pngrtran.c). */ png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0); /* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */ - png_ptr->trans_alpha = info_ptr->trans_alpha = - (png_bytep)png_malloc(png_ptr, (png_size_t)PNG_MAX_PALETTE_LENGTH); + png_ptr->trans_alpha = info_ptr->trans_alpha = png_voidcast(png_bytep, + 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); @@ -910,11 +919,11 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr, int sample_max = (1 << info_ptr->bit_depth); if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY && - (int)trans_color->gray > sample_max) || + trans_color->gray > sample_max) || (info_ptr->color_type == PNG_COLOR_TYPE_RGB && - ((int)trans_color->red > sample_max || - (int)trans_color->green > sample_max || - (int)trans_color->blue > sample_max))) + (trans_color->red > sample_max || + trans_color->green > sample_max || + trans_color->blue > sample_max))) png_warning(png_ptr, "tRNS chunk has out-of-range samples for bit_depth"); @@ -937,7 +946,7 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr, #ifdef PNG_sPLT_SUPPORTED void PNGAPI -png_set_sPLT(png_structrp png_ptr, +png_set_sPLT(png_const_structrp png_ptr, png_inforp info_ptr, png_const_sPLT_tp entries, int nentries) /* * entries - array of png_sPLT_t structures @@ -1015,7 +1024,7 @@ png_set_sPLT(png_structrp png_ptr, #ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED void PNGAPI -png_set_unknown_chunks(png_structrp png_ptr, +png_set_unknown_chunks(png_const_structrp png_ptr, png_inforp info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns) { png_unknown_chunkp np; @@ -1080,7 +1089,7 @@ png_set_unknown_chunks(png_structrp png_ptr, } void PNGAPI -png_set_unknown_chunk_location(png_structrp png_ptr, png_inforp info_ptr, +png_set_unknown_chunk_location(png_const_structrp png_ptr, png_inforp info_ptr, int chunk, int location) { if (png_ptr != NULL && info_ptr != NULL && chunk >= 0 && chunk < @@ -1097,19 +1106,18 @@ png_permit_mng_features (png_structrp png_ptr, png_uint_32 mng_features) png_debug(1, "in png_permit_mng_features"); if (png_ptr == NULL) - return (png_uint_32)0; + return 0; - png_ptr->mng_features_permitted = - (png_byte)(mng_features & PNG_ALL_MNG_FEATURES); + png_ptr->mng_features_permitted = mng_features & PNG_ALL_MNG_FEATURES; - return (png_uint_32)png_ptr->mng_features_permitted; + return png_ptr->mng_features_permitted; } #endif #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED void PNGAPI -png_set_keep_unknown_chunks(png_structrp png_ptr, int keep, png_const_bytep - chunk_list, int num_chunks) +png_set_keep_unknown_chunks(png_structrp png_ptr, int keep, + png_const_bytep chunk_list, int num_chunks) { png_bytep new_list, p; int i, old_num_chunks; @@ -1142,14 +1150,12 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep, png_const_bytep if (png_ptr->chunk_list != NULL) { - png_memcpy(new_list, png_ptr->chunk_list, - (png_size_t)(5*old_num_chunks)); + png_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, - (png_size_t)(5*num_chunks)); + png_memcpy(new_list + 5*old_num_chunks, chunk_list, 5*num_chunks); for (p = new_list + 5*old_num_chunks + 4, i = 0; iuser_chunk_cache_max = user_chunk_cache_max; diff --git a/pngstruct.h b/pngstruct.h index 568c48fb7..1ce804240 100644 --- a/pngstruct.h +++ b/pngstruct.h @@ -238,10 +238,6 @@ struct png_struct_def png_bytep quantize_index; /* index translation for palette files */ #endif -#if defined(PNG_READ_QUANTIZE_SUPPORTED) || defined(PNG_hIST_SUPPORTED) - png_uint_16p hist; /* histogram */ -#endif - #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED png_byte heuristic_method; /* heuristic for row filter selection */ png_byte num_prev_filters; /* number of weights for previous rows */