[libpng16] Add "free()" and "png_free_image()" calls to example code.

This commit is contained in:
John Bowler
2011-11-27 21:39:13 -06:00
committed by Glenn Randers-Pehrson
parent 5e934ba900
commit 414769b415
3 changed files with 29 additions and 4 deletions

View File

@@ -97,6 +97,19 @@ int main(int argc, const char **argv)
exit(0);
}
}
else
{
/* Calling png_free_image is optional unless the simplified API was
* not run to completion. In this case if there wasn't enough
* memory for 'buffer' we didn't complete the read, so we must free
* the image:
*/
if (buffer == NULL)
png_free_image(&image);
else
free(buffer);
}
/* Something went wrong reading or writing the image. libpng stores a