This interface shall change the default behavior for freeing allocated data, from only freeing data allocated internally by libpng, to either freeing user-allocated data or to not freeing any data at all.
This interface can enable deallocation of user data allocated with png_malloc() or png_zalloc() and passed to libpng with one of the png_set_*() interfaces. Users can call it both before and after passing the data. Calling it after reading PNG data but before passing the data controls whether the user or the interface is responsible for the existing data. Calling it after passing the data controls whether the user or the interface should deallocate the data.
If the user becomes responsible for data allocated by libpng, png_free() must be called to free it. If libpng becomes responsible for user-allocated data, the data must only have been allocated with png_malloc() or png_zalloc().
The parameter png_ptr shall specify the PNG file.
The parameter info_ptr shall specify the PNG info structure.
The parameter freer shall specify one of these constants:
The parameter mask shall specify the data to free, as described under png_free_data().
row_pointers array allocated in a single block
must not be freed with
png_set_rows() or png_read_destroy(),
because they would attempt to free the elements of the array as well.
Do not free
text_ptr with libpng
if some of its members were allocated separately,
because this will actually only free
If responsibility for freeing
from libpng to the user, the user
must not free the members separately.