Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(691)

Unified Diff: src/images/SkImageDecoder_libjpeg.cpp

Issue 1516833003: Switch SkAutoMalloc to SkAutoTMalloc to avoid cast (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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();

Powered by Google App Engine
This is Rietveld 408576698