mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[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:
committed by
Glenn Randers-Pehrson
parent
ad41b8838a
commit
40b2603687
@@ -920,6 +920,14 @@ png_read_destroy(png_structp png_ptr)
|
||||
#endif /* PNG_TEXT_SUPPORTED */
|
||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
||||
|
||||
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||
png_free(png_ptr, png_ptr->unknown_chunk.data);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
png_free(png_ptr, png_ptr->chunk_list);
|
||||
#endif
|
||||
|
||||
/* NOTE: the 'setjmp' buffer may still be allocated and the memory and error
|
||||
* callbacks are still set at this point. They are required to complete the
|
||||
* destruction of the png_struct itself.
|
||||
|
||||
Reference in New Issue
Block a user