From bfb9fbd2fb8558532eb2223ec0281a04b2043c73 Mon Sep 17 00:00:00 2001 From: TazyFoundSoup Date: Tue, 14 Apr 2026 19:06:44 +1000 Subject: feat(png): Add ff_close_png function --- src/format/image/png.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/format/image/png.c') 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 -- cgit v1.2.3