From 5618e46179aa7fd8f8d07c4246a368fd8bb93b4a Mon Sep 17 00:00:00 2001 From: Glenn Randers-Pehrson Date: Tue, 1 Sep 2009 10:48:04 -0500 Subject: [PATCH] [devel] Eliminated PNG_NO_CALLOC and PNG_CALLOC_SUPPORTED and always use png_calloc(). The macros were only there for testing, since libpng-1.4.0beta48 and no problems have been reported. --- ANNOUNCE | 5 +++-- CHANGES | 3 ++- png.c | 4 ++-- png.h | 10 ++++------ pngconf.h | 6 ++---- pngmem.c | 4 +--- pngrtran.c | 34 +--------------------------------- pngset.c | 9 +-------- pngwutil.c | 8 +------- 9 files changed, 17 insertions(+), 66 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index f65236335..c7f1a35d5 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,5 +1,5 @@ -Libpng 1.4.0beta79 - August 31, 2009 +Libpng 1.4.0beta79 - September 1, 2009 This is not intended to be a public release. It will be replaced within a few weeks by a public version or by another test version. @@ -540,8 +540,9 @@ version 1.4.0beta78 [August 31, 2009] Use png_malloc plus a loop instead of png_calloc() to initialize row_pointers in png_read_png(). -version 1.4.0beta79 [August 31, 2009] +version 1.4.0beta79 [September 1, 2009] Eliminated PNG_GLOBAL_ARRAYS and PNG_LOCAL_ARRAYS; always use local arrays. + Eliminated PNG_CALLOC_SUPPORTED macro and always provide png_calloc(). version 1.4.0betaN [future] Build shared libraries with -lz and sometimes -lm. diff --git a/CHANGES b/CHANGES index 83ee890f7..352408a7f 100644 --- a/CHANGES +++ b/CHANGES @@ -2226,8 +2226,9 @@ version 1.4.0beta78 [August 31, 2009] Use png_malloc plus a loop instead of png_calloc() to initialize row_pointers in png_read_png(). -version 1.4.0beta79 [August 31, 2009] +version 1.4.0beta79 [September 1, 2009] Eliminated PNG_GLOBAL_ARRAYS and PNG_LOCAL_ARRAYS; always use local arrays. + Eliminated PNG_CALLOC_SUPPORTED macro and always provide png_calloc(). version 1.4.0betaN [future] Build shared libraries with -lz and sometimes -lm. diff --git a/png.c b/png.c index bf2400d70..91b73314d 100644 --- a/png.c +++ b/png.c @@ -546,13 +546,13 @@ png_get_copyright(png_structp png_ptr) #else #ifdef __STDC__ return ((png_charp) PNG_STRING_NEWLINE \ - "libpng version x 1.4.0beta79 - August 31, 2009" PNG_STRING_NEWLINE \ + "libpng version x 1.4.0beta79 - September 1, 2009" PNG_STRING_NEWLINE \ "Copyright (c) 1998-2009 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 ((png_charp) "libpng version 1.4.0beta79 - August 31, 2009\ + return ((png_charp) "libpng version 1.4.0beta79 - September 1, 2009\ Copyright (c) 1998-2009 Glenn Randers-Pehrson\ Copyright (c) 1996-1997 Andreas Dilger\ Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc."); diff --git a/png.h b/png.h index 86fdf1fcd..31188afe1 100644 --- a/png.h +++ b/png.h @@ -1,7 +1,7 @@ /* png.h - header file for PNG reference library * - * libpng version 1.4.0beta79 - August 31, 2009 + * libpng version 1.4.0beta79 - September 1, 2009 * Copyright (c) 1998-2009 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.4.0beta79 - August 31, 2009: Glenn + * libpng versions 0.97, January 1998, through 1.4.0beta79 - September 1, 2009: Glenn * See also "Contributing Authors", below. * * Note about libpng version numbers: @@ -161,7 +161,7 @@ * * This code is released under the libpng license. * - * libpng versions 1.2.6, August 15, 2004, through 1.4.0beta79, August 31, 2009, are + * libpng versions 1.2.6, August 15, 2004, through 1.4.0beta79, September 1, 2009, are * Copyright (c) 2004, 2006-2007 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: @@ -337,7 +337,7 @@ /* Version information for png.h - this should match the version in png.c */ #define PNG_LIBPNG_VER_STRING "1.4.0beta79" #define PNG_HEADER_VERSION_STRING \ - " libpng version 1.4.0beta79 - August 31, 2009\n" + " libpng version 1.4.0beta79 - September 1, 2009\n" #define PNG_LIBPNG_VER_SONUM 14 #define PNG_LIBPNG_VER_DLLNUM 14 @@ -1899,10 +1899,8 @@ extern PNG_EXPORT(void,png_progressive_combine_row) PNGARG((png_structp png_ptr, extern PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr, png_alloc_size_t size)); /* Added at libpng version 1.4.0 */ -#ifdef PNG_CALLOC_SUPPORTED extern PNG_EXPORT(png_voidp,png_calloc) PNGARG((png_structp png_ptr, png_alloc_size_t size)); -#endif /* Added at libpng version 1.2.4 */ extern PNG_EXPORT(png_voidp,png_malloc_warn) PNGARG((png_structp png_ptr, diff --git a/pngconf.h b/pngconf.h index fae6ffef7..f6d1ebee7 100644 --- a/pngconf.h +++ b/pngconf.h @@ -1,7 +1,7 @@ /* pngconf.h - machine configurable file for libpng * - * libpng version 1.4.0beta79 - August 31, 2009 + * libpng version 1.4.0beta79 - September 1, 2009 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -49,9 +49,7 @@ #endif /* Added at libpng-1.4.0beta49 for testing */ -#ifndef PNG_NO_CALLOC -# define PNG_CALLOC_SUPPORTED -#endif +#define PNG_CALLOC_SUPPORTED /* * If you create a private DLL you need to define in "pngusr.h" the followings: diff --git a/pngmem.c b/pngmem.c index 6f6907d76..ade246d97 100644 --- a/pngmem.c +++ b/pngmem.c @@ -1,7 +1,7 @@ /* pngmem.c - stub functions for memory allocation * - * Last changed in libpng 1.4.0 [August 31, 2009] + * Last changed in libpng 1.4.0 [September 1, 2009] * Copyright (c) 1998-2009 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.) @@ -114,7 +114,6 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, * result, we would be truncating potentially larger memory requests * (which should cause a fatal error) and introducing major problems. */ -#ifdef PNG_CALLOC_SUPPORTED png_voidp PNGAPI png_calloc(png_structp png_ptr, png_alloc_size_t size) { @@ -125,7 +124,6 @@ png_calloc(png_structp png_ptr, png_alloc_size_t size) png_memset(ret,0,(png_size_t)size); return (ret); } -#endif png_voidp PNGAPI png_malloc(png_structp png_ptr, png_alloc_size_t size) diff --git a/pngrtran.c b/pngrtran.c index af4c22985..f4382ce09 100644 --- a/pngrtran.c +++ b/pngrtran.c @@ -1,7 +1,7 @@ /* pngrtran.c - transforms the data in a row for PNG readers * - * Last changed in libpng 1.4.0 [August 31, 2009] + * Last changed in libpng 1.4.0 [September 1, 2009] * Copyright (c) 1998-2009 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.) @@ -351,14 +351,8 @@ png_set_dither(png_structp png_ptr, png_colorp palette, png_ptr->palette_to_index[i] = (png_byte)i; } -#ifdef PNG_CALLOC_SUPPORTED hash = (png_dsortpp)png_calloc(png_ptr, (png_uint_32)(769 * png_sizeof(png_dsortp))); -#else - hash = (png_dsortpp)png_malloc(png_ptr, (png_uint_32)(769 * - png_sizeof(png_dsortp))); - png_memset(hash, 0, 769 * png_sizeof(png_dsortp)); -#endif num_new_palette = num_palette; @@ -505,15 +499,8 @@ png_set_dither(png_structp png_ptr, png_colorp palette, int num_blue = (1 << PNG_DITHER_BLUE_BITS); png_size_t num_entries = ((png_size_t)1 << total_bits); -#ifdef PNG_CALLOC_SUPPORTED png_ptr->palette_lookup = (png_bytep )png_calloc(png_ptr, (png_uint_32)(num_entries * png_sizeof(png_byte))); -#else - png_ptr->palette_lookup = (png_bytep )png_malloc(png_ptr, - (png_uint_32)(num_entries * png_sizeof(png_byte))); - png_memset(png_ptr->palette_lookup, 0, num_entries * - png_sizeof(png_byte)); -#endif distance = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_entries * png_sizeof(png_byte))); @@ -4130,14 +4117,8 @@ png_build_gamma_table(png_structp png_ptr) else g = 1.0; -#ifdef PNG_CALLOC_SUPPORTED png_ptr->gamma_16_table = (png_uint_16pp)png_calloc(png_ptr, (png_uint_32)(num * png_sizeof(png_uint_16p))); -#else - png_ptr->gamma_16_table = (png_uint_16pp)png_malloc(png_ptr, - (png_uint_32)(num * png_sizeof(png_uint_16p))); - png_memset(png_ptr->gamma_16_table, 0, num * png_sizeof(png_uint_16p)); -#endif if (png_ptr->transformations & (PNG_16_TO_8 | PNG_BACKGROUND)) { @@ -4197,14 +4178,8 @@ png_build_gamma_table(png_structp png_ptr) g = 1.0 / (png_ptr->gamma); -#ifdef PNG_CALLOC_SUPPORTED png_ptr->gamma_16_to_1 = (png_uint_16pp)png_calloc(png_ptr, (png_uint_32)(num * png_sizeof(png_uint_16p ))); -#else - png_ptr->gamma_16_to_1 = (png_uint_16pp)png_malloc(png_ptr, - (png_uint_32)(num * png_sizeof(png_uint_16p ))); - png_memset(png_ptr->gamma_16_to_1, 0, num * png_sizeof(png_uint_16p)); -#endif for (i = 0; i < num; i++) { @@ -4227,15 +4202,8 @@ png_build_gamma_table(png_structp png_ptr) else g = png_ptr->gamma; /* Probably doing rgb_to_gray */ -#ifdef PNG_CALLOC_SUPPORTED png_ptr->gamma_16_from_1 = (png_uint_16pp)png_calloc(png_ptr, (png_uint_32)(num * png_sizeof(png_uint_16p))); -#else - png_ptr->gamma_16_from_1 = (png_uint_16pp)png_malloc(png_ptr, - (png_uint_32)(num * png_sizeof(png_uint_16p))); - png_memset(png_ptr->gamma_16_from_1, 0, - num * png_sizeof(png_uint_16p)); -#endif for (i = 0; i < num; i++) { diff --git a/pngset.c b/pngset.c index ab30aee88..6dc173481 100644 --- a/pngset.c +++ b/pngset.c @@ -1,7 +1,7 @@ /* pngset.c - storage of image information into info struct * - * Last changed in libpng 1.4.0 [August 31, 2009] + * Last changed in libpng 1.4.0 [September 1, 2009] * Copyright (c) 1998-2009 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.) @@ -526,15 +526,8 @@ png_set_PLTE(png_structp png_ptr, png_infop info_ptr, * of num_palette entries, in case of an invalid PNG file that has * too-large sample values. */ -#ifdef PNG_CALLOC_SUPPORTED png_ptr->palette = (png_colorp)png_calloc(png_ptr, PNG_MAX_PALETTE_LENGTH * png_sizeof(png_color)); -#else - png_ptr->palette = (png_colorp)png_malloc(png_ptr, - PNG_MAX_PALETTE_LENGTH * png_sizeof(png_color)); - png_memset(png_ptr->palette, 0, PNG_MAX_PALETTE_LENGTH * - png_sizeof(png_color)); -#endif png_memcpy(png_ptr->palette, palette, num_palette * png_sizeof(png_color)); info_ptr->palette = png_ptr->palette; info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette; diff --git a/pngwutil.c b/pngwutil.c index 6c11b057e..2525807a4 100644 --- a/pngwutil.c +++ b/pngwutil.c @@ -1,7 +1,7 @@ /* pngwutil.c - utilities to write a PNG file * - * Last changed in libpng 1.4.0 [August 31, 2009] + * Last changed in libpng 1.4.0 [September 1, 2009] * Copyright (c) 1998-2009 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.) @@ -1753,14 +1753,8 @@ png_write_start_row(png_structp png_ptr) if (png_ptr->do_filter & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH)) { /* Set up previous row buffer */ -#ifdef PNG_CALLOC_SUPPORTED png_ptr->prev_row = (png_bytep)png_calloc(png_ptr, (png_alloc_size_t)buf_size); -#else - png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, - (png_uint_32)buf_size); - png_memset(png_ptr->prev_row, 0, buf_size); -#endif if (png_ptr->do_filter & PNG_FILTER_UP) {