summaryrefslogtreecommitdiff
path: root/example.c
diff options
context:
space:
mode:
authorJohn Bowler <jbowler@acm.org>2011-11-27 21:39:13 -0600
committerGlenn Randers-Pehrson <glennrp at users.sourceforge.net>2011-11-27 21:39:13 -0600
commit414769b415f491cebdbf4c727c940f5c99d523ba (patch)
tree621c5c2c036bf29ebd8a65852e075d23127fae63 /example.c
parent5e934ba90076282f1d795b3112820ef0825ea181 (diff)
[libpng16] Add "free()" and "png_free_image()" calls to example code.
Diffstat (limited to 'example.c')
-rw-r--r--example.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/example.c b/example.c
index e8bfdd093..c63ef1c35 100644
--- a/example.c
+++ b/example.c
@@ -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