[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-21 17:36:12 -06:00
committed by Glenn Randers-Pehrson
parent b74fb4e49c
commit d332c67da7
9 changed files with 476 additions and 451 deletions

View File

@@ -29,8 +29,10 @@
struct png_struct_def
{
#ifdef PNG_SETJMP_SUPPORTED
jmp_buf longjmp_buffer; /* used in png_error */
png_longjmp_ptr longjmp_fn;/* setjmp non-local goto function. */
jmp_buf *jmp_buf_ptr; /* passed to longjmp_fn */
size_t jmp_buf_size; /* size of the above, if allocated */
jmp_buf jmp_buf_local; /* New name in 1.6.0 for jmp_buf in png_struct */
#endif
png_error_ptr error_fn; /* function for printing errors and aborting */
#ifdef PNG_WARNINGS_SUPPORTED