From d2e225e8dc828690009cbeba62070dec85380e4e Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Sat, 15 Feb 2025 12:27:12 +0100 Subject: [PATCH] change alloc pixels array with pnm alloc --- src/kds_s2000w_image_converter_netpbm.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/kds_s2000w_image_converter_netpbm.c b/src/kds_s2000w_image_converter_netpbm.c index da5a6cf..942e446 100644 --- a/src/kds_s2000w_image_converter_netpbm.c +++ b/src/kds_s2000w_image_converter_netpbm.c @@ -229,9 +229,8 @@ void _kds_s2000w_image_converter_write_pnm(uint8_t* data, { kds_s2000w_debug_printf(ALL, "kds_s2000w_image_converter_write_pnm"); - xel** pixels = malloc(sizeof(xel*) * height); + xel** pixels = pnm_allocarray(width, height); for (uint32_t i = 0; i < height; i++) { - pixels[i] = malloc(sizeof(xel) * width); memset(pixels[i], 0, sizeof(xel) * width); } @@ -258,11 +257,7 @@ void _kds_s2000w_image_converter_write_pnm(uint8_t* data, else pnm_writepnm(pnm_stream, pixels, width, height, PGM_MAXMAXVAL, PGM_FORMAT, 0); - for (uint32_t i = 0; i < height; i++) { - free(pixels[i]); - pixels[i] = NULL; - } - free(pixels); + pnm_freearray(pixels, height); pixels = NULL; } -- 2.39.5