]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
change alloc pixels array with pnm alloc
authorBastian Dehn <hhaalo@arcor.de>
Sat, 15 Feb 2025 11:27:12 +0000 (12:27 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sat, 15 Feb 2025 13:34:10 +0000 (14:34 +0100)
src/kds_s2000w_image_converter_netpbm.c

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