]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
allow bw pnm with pnm alloc
authorBastian Dehn <hhaalo@arcor.de>
Sat, 15 Feb 2025 11:29:45 +0000 (12:29 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sat, 15 Feb 2025 13:35:08 +0000 (14:35 +0100)
src/kds_s2000w_image_converter_netpbm.c

index 942e446e54be97db16838dfce1d5a862026b6e48..c2c39d8458b6d30cd9badb86c48757a7ceeb0908 100644 (file)
@@ -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;
 }