summaryrefslogtreecommitdiff
path: root/src/format/image
diff options
context:
space:
mode:
Diffstat (limited to 'src/format/image')
-rw-r--r--src/format/image/png.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/format/image/png.c b/src/format/image/png.c
index 15f05b8..f42761b 100644
--- a/src/format/image/png.c
+++ b/src/format/image/png.c
@@ -449,4 +449,24 @@ ff_result ff_png_trans_handler(ff_ctx* ctx, uint8_t *buf, size_t len, ff_png_ctx
}
-// TODO: Add ff_close_png \ No newline at end of file
+ff_result ff_close_png(ff_ctx* ctx, ff_png_ctx *png_ctx)
+{
+ if (!png_ctx) return FF_RESULT_OK;
+
+ if (png_ctx->data.pixels) {
+ ctx->allocator.ff_free(png_ctx->data.pixels);
+ png_ctx->data.pixels = NULL;
+ ff_dprintf(ctx, "png: successfully freed pixels\n");
+ }
+
+ if (png_ctx->data.imap) {
+ ctx->allocator.ff_free(png_ctx->data.imap);
+ png_ctx->data.imap = NULL;
+ ff_dprintf(ctx, "png: successfully freed index map\n");
+ }
+
+ ctx->allocator.ff_free(png_ctx);
+ ff_dprintf(ctx, "png: successfully freed png context\n");
+
+ return FF_RESULT_OK;
+} \ No newline at end of file