Chromium Code Reviews| Index: src/images/SkImageDecoder_libjpeg.cpp |
| diff --git a/src/images/SkImageDecoder_libjpeg.cpp b/src/images/SkImageDecoder_libjpeg.cpp |
| index 219dad6db220cd67dce4daea57ce2f3bc1a71381..4a1b6726a5eb4972e045622af98da029589efb65 100644 |
| --- a/src/images/SkImageDecoder_libjpeg.cpp |
| +++ b/src/images/SkImageDecoder_libjpeg.cpp |
| @@ -496,8 +496,8 @@ SkImageDecoder::Result SkJPEGImageDecoder::onDecode(SkStream* stream, SkBitmap* |
| return return_failure(cinfo, *bm, "sampler.begin"); |
| } |
| - SkAutoMalloc srcStorage(cinfo.output_width * srcBytesPerPixel); |
| - uint8_t* srcRow = (uint8_t*)srcStorage.get(); |
| + SkAutoTMalloc<uint8_t> srcStorage(cinfo.output_width * srcBytesPerPixel); |
| + uint8_t* srcRow = srcStorage.get(); |
| // Possibly skip initial rows [sampler.srcY0] |
| if (!skip_src_rows(&cinfo, srcRow, sampler.srcY0())) { |
| @@ -931,7 +931,7 @@ protected: |
| skjpeg_destination_mgr sk_wstream(stream); |
| // allocate these before set call setjmp |
| - SkAutoMalloc oneRow; |
| + SkAutoTMalloc<uint8_t> oneRow; |
| cinfo.err = jpeg_std_error(&sk_err); |
| sk_err.error_exit = skjpeg_error_exit; |
| @@ -966,7 +966,8 @@ protected: |
| jpeg_start_compress(&cinfo, TRUE); |
| const int width = bm.width(); |
| - uint8_t* oneRowP = (uint8_t*)oneRow.reset(width * 3); |
| + oneRow.reset(width * 3); |
|
scroggo
2015/12/10 15:53:34
I could change SkAutoTMalloc::reset to return fPtr
mtklein
2015/12/10 16:00:02
Sure. Seems fine either way.
|
| + uint8_t* oneRowP = oneRow.get(); |
| const SkPMColor* colors = bm.getColorTable() ? bm.getColorTable()->readColors() : nullptr; |
| const void* srcRow = bm.getPixels(); |