[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

9
png.h
View File

@@ -1065,8 +1065,8 @@ PNG_EXPORT(17, void, png_write_chunk_end, (png_structp png_ptr));
PNG_EXPORTA(18, png_infop, png_create_info_struct, (png_structp png_ptr),
PNG_ALLOCATED);
PNG_EXPORT(19, void, png_info_init_3, (png_infopp info_ptr,
png_size_t png_info_struct_size));
PNG_EXPORTA(19, void, png_info_init_3, (png_infopp info_ptr,
png_size_t png_info_struct_size), PNG_DEPRECATED);
/* Writes all the PNG information before the image. */
PNG_EXPORT(20, void, png_write_info_before_PLTE,
@@ -1894,8 +1894,9 @@ PNG_EXPORT(99, void, png_data_freer,
#ifdef PNG_USER_MEM_SUPPORTED
PNG_EXPORTA(100, png_voidp, png_malloc_default, (png_structp png_ptr,
png_alloc_size_t size), PNG_ALLOCATED);
PNG_EXPORT(101, void, png_free_default, (png_structp png_ptr, png_voidp ptr));
png_alloc_size_t size), PNG_ALLOCATED PNG_DEPRECATED);
PNG_EXPORTA(101, void, png_free_default, (png_structp png_ptr, png_voidp ptr),
PNG_DEPRECATED);
#endif
#ifdef PNG_ERROR_TEXT_SUPPORTED