[libpng16] Start-up code size improvements, error handler flexibility. These

changes alter how the tricky allocation of the initial png_struct and png_info
structures are handled. png_info is now handled in pretty much the same
way as everything else, except that the allocations handle NULL return
silently.  png_struct is changed in a similar way on allocation and on
deallocation a 'safety' error handler is put in place (which should never
be required).  The error handler itself is changed to permit mismatches
in the application and libpng error buffer size; however, this means a
silent change to the API to return the jmp_buf if the size doesn't match
the size from the libpng compilation; libpng now allocates the memory and
this may fail.  Overall these changes result in slight code size
reductions; however, this is a reduction in code that is always executed
so is particularly valuable.  Overall on a 64-bit system the libpng DLL
decreases in code size by 1733 bytes.  pngerror.o increases in size by
about 465 bytes because of the new functionality.
This commit is contained in:
John Bowler
2011-12-22 08:09:15 -06:00
committed by Glenn Randers-Pehrson
parent ad41b8838a
commit 40b2603687
13 changed files with 305 additions and 311 deletions

View File

@@ -140,8 +140,10 @@ struct png_struct_def
/* pixel depth used for the row buffers */
png_byte transformed_pixel_depth;
/* pixel depth after read/write transforms */
#if PNG_LIBPNG_VER < 10600
png_byte io_chunk_string[5];
/* string name of chunk */
#endif
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
png_uint_16 filler; /* filler bytes for pixel expansion */
@@ -250,9 +252,11 @@ struct png_struct_def
png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */
#endif
#if PNG_LIBPNG_VER < 10700
#ifdef PNG_TIME_RFC1123_SUPPORTED
char time_buffer[29]; /* String to hold RFC 1123 time text */
#endif
#endif
/* New members added in libpng-1.0.6 */
@@ -338,9 +342,13 @@ struct png_struct_def
/* New member added in libpng-1.0.25 and 1.2.17 */
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
/* Storage for unknown chunk that the library doesn't recognize. */
/* Temporary storage for unknown chunk that the library doesn't recognize,
* used while reading the chunk.
*/
#ifdef PNG_READ_SUPPORTED
png_unknown_chunk unknown_chunk;
#endif
#endif
/* New member added in libpng-1.2.26 */
png_size_t old_big_row_buf_size;