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);
}
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;
}