[devel] Eliminated PNG_NO_FREE_ME and PNG_FREE_ME_SUPPORTED macros

They were only useful for obtaining compatibility for old applications
that used libpng-1.0.x versions prior to the implementation of "free_me".
This commit is contained in:
Glenn Randers-Pehrson 2009-08-31 09:02:37 -05:00
parent dbd4014239
commit 0af5378d4d
5 changed files with 7 additions and 110 deletions

View File

@ -1,5 +1,5 @@
Libpng 1.4.0beta78 - August 29, 2009
Libpng 1.4.0beta78 - August 31, 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.
@ -534,7 +534,9 @@ version 1.4.0beta77 [August 27, 2009]
Moved CMakeLists.txt from scripts into the main libpng directory.
Various bugfixes and improvements to CMakeLists.txt (Philip Lowman)
version 1.4.0beta78 [August 29, 2009]
version 1.4.0beta78 [August 31, 2009]
Converted all PNG_NO_* tests to PNG_*_SUPPORTED everywhere except pngconf.h
Eliminated PNG_NO_FREE_ME and PNG_FREE_ME_SUPPORTED macros.
version 1.4.0betaN [future]
Build shared libraries with -lz and sometimes -lm.

View File

@ -2220,7 +2220,9 @@ version 1.4.0beta77 [August 27, 2009]
Moved CMakeLists.txt from scripts into the main libpng directory.
Various bugfixes and improvements to CMakeLists.txt (Philip Lowman)
version 1.4.0beta78 [August 29, 2009]
version 1.4.0beta78 [August 31, 2009]
Converted all PNG_NO_* tests to PNG_*_SUPPORTED everywhere except pngconf.h
Eliminated PNG_NO_FREE_ME and PNG_FREE_ME_SUPPORTED macros.
version 1.4.0betaN [future]
Build shared libraries with -lz and sometimes -lm.

53
png.c
View File

@ -288,7 +288,6 @@ png_info_init_3(png_infopp ptr_ptr, png_size_t png_info_struct_size)
png_memset(info_ptr, 0, png_sizeof(png_info));
}
#ifdef PNG_FREE_ME_SUPPORTED
void PNGAPI
png_data_freer(png_structp png_ptr, png_infop info_ptr,
int freer, png_uint_32 mask)
@ -306,7 +305,6 @@ png_data_freer(png_structp png_ptr, png_infop info_ptr,
png_warning(png_ptr,
"Unknown freer parameter in png_data_freer");
}
#endif
void PNGAPI
png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask,
@ -319,11 +317,7 @@ png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask,
#if defined(PNG_TEXT_SUPPORTED)
/* Free text item num or (if num == -1) all text items */
#ifdef PNG_FREE_ME_SUPPORTED
if ((mask & PNG_FREE_TEXT) & info_ptr->free_me)
#else
if (mask & PNG_FREE_TEXT)
#endif
{
if (num != -1)
{
@ -347,28 +341,17 @@ png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask,
#if defined(PNG_tRNS_SUPPORTED)
/* Free any tRNS entry */
#ifdef PNG_FREE_ME_SUPPORTED
if ((mask & PNG_FREE_TRNS) & info_ptr->free_me)
#else
if ((mask & PNG_FREE_TRNS) && (png_ptr->flags & PNG_FLAG_FREE_TRNS))
#endif
{
png_free(png_ptr, info_ptr->trans_alpha);
info_ptr->trans_alpha = NULL;
info_ptr->valid &= ~PNG_INFO_tRNS;
#ifndef PNG_FREE_ME_SUPPORTED
png_ptr->flags &= ~PNG_FLAG_FREE_TRNS;
#endif
}
#endif
#if defined(PNG_sCAL_SUPPORTED)
/* Free any sCAL entry */
#ifdef PNG_FREE_ME_SUPPORTED
if ((mask & PNG_FREE_SCAL) & info_ptr->free_me)
#else
if (mask & PNG_FREE_SCAL)
#endif
{
#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED)
png_free(png_ptr, info_ptr->scal_s_width);
@ -382,11 +365,7 @@ png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask,
#if defined(PNG_pCAL_SUPPORTED)
/* Free any pCAL entry */
#ifdef PNG_FREE_ME_SUPPORTED
if ((mask & PNG_FREE_PCAL) & info_ptr->free_me)
#else
if (mask & PNG_FREE_PCAL)
#endif
{
png_free(png_ptr, info_ptr->pcal_purpose);
png_free(png_ptr, info_ptr->pcal_units);
@ -409,11 +388,7 @@ png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask,
#if defined(PNG_iCCP_SUPPORTED)
/* Free any iCCP entry */
#ifdef PNG_FREE_ME_SUPPORTED
if ((mask & PNG_FREE_ICCP) & info_ptr->free_me)
#else
if (mask & PNG_FREE_ICCP)
#endif
{
png_free(png_ptr, info_ptr->iccp_name);
png_free(png_ptr, info_ptr->iccp_profile);
@ -425,11 +400,7 @@ png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask,
#if defined(PNG_sPLT_SUPPORTED)
/* Free a given sPLT entry, or (if num == -1) all sPLT entries */
#ifdef PNG_FREE_ME_SUPPORTED
if ((mask & PNG_FREE_SPLT) & info_ptr->free_me)
#else
if (mask & PNG_FREE_SPLT)
#endif
{
if (num != -1)
{
@ -465,11 +436,7 @@ png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask,
png_ptr->unknown_chunk.data = NULL;
}
#ifdef PNG_FREE_ME_SUPPORTED
if ((mask & PNG_FREE_UNKN) & info_ptr->free_me)
#else
if (mask & PNG_FREE_UNKN)
#endif
{
if (num != -1)
{
@ -498,44 +465,26 @@ png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask,
#if defined(PNG_hIST_SUPPORTED)
/* Free any hIST entry */
#ifdef PNG_FREE_ME_SUPPORTED
if ((mask & PNG_FREE_HIST) & info_ptr->free_me)
#else
if ((mask & PNG_FREE_HIST) && (png_ptr->flags & PNG_FLAG_FREE_HIST))
#endif
{
png_free(png_ptr, info_ptr->hist);
info_ptr->hist = NULL;
info_ptr->valid &= ~PNG_INFO_hIST;
#ifndef PNG_FREE_ME_SUPPORTED
png_ptr->flags &= ~PNG_FLAG_FREE_HIST;
#endif
}
#endif
/* Free any PLTE entry that was internally allocated */
#ifdef PNG_FREE_ME_SUPPORTED
if ((mask & PNG_FREE_PLTE) & info_ptr->free_me)
#else
if ((mask & PNG_FREE_PLTE) && (png_ptr->flags & PNG_FLAG_FREE_PLTE))
#endif
{
png_zfree(png_ptr, info_ptr->palette);
info_ptr->palette = NULL;
info_ptr->valid &= ~PNG_INFO_PLTE;
#ifndef PNG_FREE_ME_SUPPORTED
png_ptr->flags &= ~PNG_FLAG_FREE_PLTE;
#endif
info_ptr->num_palette = 0;
}
#if defined(PNG_INFO_IMAGE_SUPPORTED)
/* Free any image bits attached to the info structure */
#ifdef PNG_FREE_ME_SUPPORTED
if ((mask & PNG_FREE_ROWS) & info_ptr->free_me)
#else
if (mask & PNG_FREE_ROWS)
#endif
{
if (info_ptr->row_pointers)
{
@ -550,12 +499,10 @@ png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask,
}
#endif
#ifdef PNG_FREE_ME_SUPPORTED
if (num == -1)
info_ptr->free_me &= ~mask;
else
info_ptr->free_me &= ~(mask & ~PNG_FREE_MUL);
#endif
}
/* This is an internal routine to free any memory that the info struct is

View File

@ -1078,37 +1078,19 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
png_free(png_ptr, png_ptr->gamma_from_1);
png_free(png_ptr, png_ptr->gamma_to_1);
#endif
#ifdef PNG_FREE_ME_SUPPORTED
if (png_ptr->free_me & PNG_FREE_PLTE)
png_zfree(png_ptr, png_ptr->palette);
png_ptr->free_me &= ~PNG_FREE_PLTE;
#else
if (png_ptr->flags & PNG_FLAG_FREE_PLTE)
png_zfree(png_ptr, png_ptr->palette);
png_ptr->flags &= ~PNG_FLAG_FREE_PLTE;
#endif
#if defined(PNG_tRNS_SUPPORTED) || \
defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
#ifdef PNG_FREE_ME_SUPPORTED
if (png_ptr->free_me & PNG_FREE_TRNS)
png_free(png_ptr, png_ptr->trans_alpha);
png_ptr->free_me &= ~PNG_FREE_TRNS;
#else
if (png_ptr->flags & PNG_FLAG_FREE_TRNS)
png_free(png_ptr, png_ptr->trans_alpha);
png_ptr->flags &= ~PNG_FLAG_FREE_TRNS;
#endif
#endif
#if defined(PNG_READ_hIST_SUPPORTED)
#ifdef PNG_FREE_ME_SUPPORTED
if (png_ptr->free_me & PNG_FREE_HIST)
png_free(png_ptr, png_ptr->hist);
png_ptr->free_me &= ~PNG_FREE_HIST;
#else
if (png_ptr->flags & PNG_FLAG_FREE_HIST)
png_free(png_ptr, png_ptr->hist);
png_ptr->flags &= ~PNG_FLAG_FREE_HIST;
#endif
#endif
#if defined(PNG_READ_GAMMA_SUPPORTED)
if (png_ptr->gamma_16_table != NULL)
@ -1332,9 +1314,7 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
/* -------------- image transformations end here ------------------- */
#ifdef PNG_FREE_ME_SUPPORTED
png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0);
#endif
if (info_ptr->row_pointers == NULL)
{
#ifdef PNG_CALLOC_SUPPORTED
@ -1346,9 +1326,7 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
png_memset(info_ptr->row_pointers, 0, info_ptr->height
* png_sizeof(png_bytep));
#endif
#ifdef PNG_FREE_ME_SUPPORTED
info_ptr->free_me |= PNG_FREE_ROWS;
#endif
for (row = 0; row < (int)info_ptr->height; row++)
info_ptr->row_pointers[row] = (png_bytep)png_malloc(png_ptr,
png_get_rowbytes(png_ptr, info_ptr));

View File

@ -195,9 +195,7 @@ png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist)
return;
}
#ifdef PNG_FREE_ME_SUPPORTED
png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0);
#endif
/* Changed from info->num_palette to PNG_MAX_PALETTE_LENGTH in
* version 1.2.1
*/
@ -214,11 +212,7 @@ png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist)
info_ptr->hist = png_ptr->hist;
info_ptr->valid |= PNG_INFO_hIST;
#ifdef PNG_FREE_ME_SUPPORTED
info_ptr->free_me |= PNG_FREE_HIST;
#else
png_ptr->flags |= PNG_FLAG_FREE_HIST;
#endif
}
#endif
@ -415,9 +409,7 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
}
info_ptr->valid |= PNG_INFO_pCAL;
#ifdef PNG_FREE_ME_SUPPORTED
info_ptr->free_me |= PNG_FREE_PCAL;
#endif
}
#endif
@ -479,9 +471,7 @@ png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr,
}
png_memcpy(info_ptr->scal_s_height, sheight, length);
info_ptr->valid |= PNG_INFO_sCAL;
#ifdef PNG_FREE_ME_SUPPORTED
info_ptr->free_me |= PNG_FREE_SCAL;
#endif
}
#endif
#endif
@ -530,9 +520,7 @@ png_set_PLTE(png_structp png_ptr, png_infop info_ptr,
* we do it for backward compatibility with the way the png_handle_tRNS
* function used to do the allocation.
*/
#ifdef PNG_FREE_ME_SUPPORTED
png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0);
#endif
/* Changed in libpng-1.2.1 to allocate PNG_MAX_PALETTE_LENGTH instead
* of num_palette entries, in case of an invalid PNG file that has
@ -551,11 +539,7 @@ png_set_PLTE(png_structp png_ptr, png_infop info_ptr,
info_ptr->palette = png_ptr->palette;
info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette;
#ifdef PNG_FREE_ME_SUPPORTED
info_ptr->free_me |= PNG_FREE_PLTE;
#else
png_ptr->flags |= PNG_FLAG_FREE_PLTE;
#endif
info_ptr->valid |= PNG_INFO_PLTE;
}
@ -708,9 +692,7 @@ png_set_iCCP(png_structp png_ptr, png_infop info_ptr,
/* Compression is always zero but is here so the API and info structure
* does not have to change if we introduce multiple compression types */
info_ptr->iccp_compression = (png_byte)compression_type;
#ifdef PNG_FREE_ME_SUPPORTED
info_ptr->free_me |= PNG_FREE_ICCP;
#endif
info_ptr->valid |= PNG_INFO_iCCP;
}
#endif
@ -771,9 +753,7 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
(png_size_t)(info_ptr->max_text * png_sizeof(png_text)));
if (info_ptr->text == NULL)
return(1);
#ifdef PNG_FREE_ME_SUPPORTED
info_ptr->free_me |= PNG_FREE_TEXT;
#endif
}
png_debug1(3, "allocated %d entries for info_ptr->text",
info_ptr->max_text);
@ -921,9 +901,7 @@ png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
* function used to do the allocation.
*/
#ifdef PNG_FREE_ME_SUPPORTED
png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0);
#endif
/* 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,
@ -953,11 +931,7 @@ png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
if (num_trans != 0)
{
info_ptr->valid |= PNG_INFO_tRNS;
#ifdef PNG_FREE_ME_SUPPORTED
info_ptr->free_me |= PNG_FREE_TRNS;
#else
png_ptr->flags |= PNG_FLAG_FREE_TRNS;
#endif
}
}
#endif
@ -1028,9 +1002,7 @@ png_set_sPLT(png_structp png_ptr,
info_ptr->splt_palettes = np;
info_ptr->splt_palettes_num += nentries;
info_ptr->valid |= PNG_INFO_sPLT;
#ifdef PNG_FREE_ME_SUPPORTED
info_ptr->free_me |= PNG_FREE_SPLT;
#endif
}
#endif /* PNG_sPLT_SUPPORTED */
@ -1091,9 +1063,7 @@ png_set_unknown_chunks(png_structp png_ptr,
info_ptr->unknown_chunks = np;
info_ptr->unknown_chunks_num += num_unknowns;
#ifdef PNG_FREE_ME_SUPPORTED
info_ptr->free_me |= PNG_FREE_UNKN;
#endif
}
void PNGAPI
png_set_unknown_chunk_location(png_structp png_ptr, png_infop info_ptr,
@ -1161,9 +1131,7 @@ png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_bytep
*p=(png_byte)keep;
png_ptr->num_chunk_list = old_num_chunks + num_chunks;
png_ptr->chunk_list = new_list;
#ifdef PNG_FREE_ME_SUPPORTED
png_ptr->free_me |= PNG_FREE_LIST;
#endif
}
#endif