From: Bastian Dehn Date: Sat, 15 Feb 2025 11:29:45 +0000 (+0100) Subject: allow bw pnm with pnm alloc X-Git-Tag: v1.0.36^2~3 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=56bc3cb6bda6060cfd27a6877b67ad9ae4eadf27;p=sane-kds-s2000w-net.git allow bw pnm with pnm alloc --- diff --git a/src/kds_s2000w_image_converter_netpbm.c b/src/kds_s2000w_image_converter_netpbm.c index 942e446..c2c39d8 100644 --- a/src/kds_s2000w_image_converter_netpbm.c +++ b/src/kds_s2000w_image_converter_netpbm.c @@ -192,9 +192,8 @@ void _kds_s2000w_image_converter_write_bw_pnm(uint8_t* data, kds_s2000w_debug_printf(ALL, "kds_s2000w_image_converter_write_bw_pnm"); uint32_t bit_witdth = width * BYTE_BITS; - xel** pixels = malloc(sizeof(xel*) * height); + xel** pixels = pnm_allocarray(bit_witdth, height); for (uint32_t i = 0; i < height; i++) { - pixels[i] = malloc(sizeof(xel) * bit_witdth); memset(pixels[i], 0, sizeof(xel) * bit_witdth); } @@ -212,11 +211,7 @@ void _kds_s2000w_image_converter_write_bw_pnm(uint8_t* data, pnm_writepnm(pnm_stream, pixels, width, height, PNM_MAXMAXVAL, PBM_FORMAT, 0); - for (uint32_t i = 0; i < height; i++) { - free(pixels[i]); - pixels[i] = NULL; - } - free(pixels); + pnm_freearray(pixels, height); pixels = NULL; }