File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -338,11 +338,12 @@ read_data(xel *array, xelval *alpha_data) {
338
338
// format, mainly because we keep array and alpha data separately, and there
339
339
// doesn't appear to be good support to get this stuff out row-at-a-time for
340
340
// interlaced files.
341
- png_bytep *rows = (png_bytep *)PANDA_MALLOC_ARRAY (num_rows * sizeof (png_bytep));
341
+ png_bytep *rows = (png_bytep *)alloca (num_rows * sizeof (png_bytep));
342
342
int yi;
343
343
344
+ png_byte *alloc = (png_byte *)PANDA_MALLOC_ARRAY (row_byte_length * sizeof (png_byte) * num_rows);
344
345
for (yi = 0 ; yi < num_rows; yi++) {
345
- rows[yi] = (png_byte *) PANDA_MALLOC_ARRAY (row_byte_length * sizeof (png_byte));
346
+ rows[yi] = alloc + (row_byte_length * sizeof (png_byte)) * yi ;
346
347
}
347
348
348
349
png_read_image (_png, rows);
@@ -402,12 +403,10 @@ read_data(xel *array, xelval *alpha_data) {
402
403
}
403
404
404
405
nassertr (source <= rows[yi] + row_byte_length, yi);
405
- PANDA_FREE_ARRAY (rows[yi]);
406
406
}
407
407
408
- PANDA_FREE_ARRAY (rows);
409
-
410
408
png_read_end (_png, nullptr );
409
+ PANDA_FREE_ARRAY (alloc);
411
410
412
411
return _y_size;
413
412
}
You can’t perform that action at this time.
0 commit comments