[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.
diff --git a/pngset.c b/pngset.c
index af5511b..5035caf 100644
--- a/pngset.c
+++ b/pngset.c
@@ -1024,9 +1024,9 @@
if (png_ptr == NULL || info_ptr == NULL || num_unknowns == 0)
return;
- np = (png_unknown_chunkp)png_malloc_warn(png_ptr,
+ np = png_voidcast(png_unknown_chunkp, png_malloc_warn(png_ptr,
(png_size_t)(info_ptr->unknown_chunks_num + num_unknowns) *
- png_sizeof(png_unknown_chunk));
+ png_sizeof(png_unknown_chunk)));
if (np == NULL)
{
@@ -1223,7 +1223,7 @@
}
void PNGAPI
-png_set_invalid(png_structp png_ptr, png_infop info_ptr, int mask)
+png_set_invalid(png_const_structp png_ptr, png_infop info_ptr, int mask)
{
if (png_ptr && info_ptr)
info_ptr->valid &= ~mask;