[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.
This commit is contained in:
Glenn Randers-Pehrson 2009-09-01 10:48:04 -05:00
parent b380515c84
commit 5618e46179
9 changed files with 17 additions and 66 deletions

View File

@ -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.

View File

@ -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.

4
png.c
View File

@ -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.");

10
png.h
View File

@ -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,

View File

@ -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:

View File

@ -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)

View File

@ -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++)
{

View File

@ -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;

View File

@ -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)
{