diff options
author | mtklein <mtklein@chromium.org> | 2016-03-17 10:51:27 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-17 10:51:27 -0700 |
commit | 852f15da7ceb53cfb49b9f728baa6dbc53b27694 (patch) | |
tree | 31449f58fc3d72056c5661ca81c43d6055237ebe /src | |
parent | 9ce9d6772df650ceb0511f275e1a83dffa78ff72 (diff) |
free -> reset
The C++ standard library uses ".reset()" where we sometimes write ".free()".
We also use ".reset()" quite a lot. This standardizes on ".reset()".
This is one more step towards dropping SkAutoTDelete in favor of the standard
std::unique_ptr.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1811723002
Committed: https://skia.googlesource.com/skia/+/0e3738db89e86035ed5d4f629bf58b817b1e5274
Review URL: https://codereview.chromium.org/1811723002
Diffstat (limited to 'src')
-rw-r--r-- | src/codec/SkBmpCodec.cpp | 2 | ||||
-rw-r--r-- | src/codec/SkJpegCodec.cpp | 2 | ||||
-rw-r--r-- | src/codec/SkRawCodec.cpp | 2 | ||||
-rw-r--r-- | src/core/SkAdvancedTypefaceMetrics.cpp | 2 | ||||
-rw-r--r-- | src/core/SkAdvancedTypefaceMetrics.h | 3 | ||||
-rw-r--r-- | src/gpu/GrGlyph.h | 6 | ||||
-rw-r--r-- | src/gpu/GrLayerCache.cpp | 2 | ||||
-rw-r--r-- | src/gpu/text/GrBatchFontCache.cpp | 2 | ||||
-rw-r--r-- | src/images/SkImageDecoder_libwebp.cpp | 2 | ||||
-rw-r--r-- | src/pdf/SkPDFDevice.cpp | 4 | ||||
-rwxr-xr-x | src/utils/SkBitSet.cpp | 2 | ||||
-rw-r--r-- | src/xml/SkDOM.cpp | 2 |
12 files changed, 15 insertions, 16 deletions
diff --git a/src/codec/SkBmpCodec.cpp b/src/codec/SkBmpCodec.cpp index 32f1d15277..e327f79018 100644 --- a/src/codec/SkBmpCodec.cpp +++ b/src/codec/SkBmpCodec.cpp @@ -392,7 +392,7 @@ bool SkBmpCodec::ReadHeader(SkStream* stream, bool inIco, SkCodec** codecOut) { alphaType = kUnpremul_SkAlphaType; } } - iBuffer.free(); + iBuffer.reset(); // Additionally, 32 bit bmp-in-icos use the alpha channel. // FIXME (msarett): Don't all bmp-in-icos use the alpha channel? diff --git a/src/codec/SkJpegCodec.cpp b/src/codec/SkJpegCodec.cpp index 2534a5f123..a342cd8b6a 100644 --- a/src/codec/SkJpegCodec.cpp +++ b/src/codec/SkJpegCodec.cpp @@ -413,7 +413,7 @@ SkCodec::Result SkJpegCodec::onStartScanlineDecode(const SkImageInfo& dstInfo, // Remove objects used for sampling. fSwizzler.reset(nullptr); fSrcRow = nullptr; - fStorage.free(); + fStorage.reset(); // Now, given valid output dimensions, we can start the decompress if (!jpeg_start_decompress(fDecoderMgr->dinfo())) { diff --git a/src/codec/SkRawCodec.cpp b/src/codec/SkRawCodec.cpp index 208bd8952d..3b7b9a96ee 100644 --- a/src/codec/SkRawCodec.cpp +++ b/src/codec/SkRawCodec.cpp @@ -381,7 +381,7 @@ public: if (fStream->getMemoryBase()) { // directly copy if getMemoryBase() is available. SkAutoTUnref<SkData> data(SkData::NewWithCopy( static_cast<const uint8_t*>(fStream->getMemoryBase()) + offset, bytesToRead)); - fStream.free(); + fStream.reset(); return new SkMemoryStream(data); } else { SkAutoTUnref<SkData> data(SkData::NewUninitialized(bytesToRead)); diff --git a/src/core/SkAdvancedTypefaceMetrics.cpp b/src/core/SkAdvancedTypefaceMetrics.cpp index b5b49e3ac5..28079f98e9 100644 --- a/src/core/SkAdvancedTypefaceMetrics.cpp +++ b/src/core/SkAdvancedTypefaceMetrics.cpp @@ -245,7 +245,7 @@ SkAdvancedTypefaceMetrics::AdvanceMetric<Data>* getAdvanceData( if (curRange->fStartId == lastIndex) { SkASSERT(prevRange); SkASSERT(prevRange->fNext->fStartId == lastIndex); - prevRange->fNext.free(); + prevRange->fNext.reset(); } else { finishRange(curRange, lastIndex - 1, SkAdvancedTypefaceMetrics::WidthRange::kRange); diff --git a/src/core/SkAdvancedTypefaceMetrics.h b/src/core/SkAdvancedTypefaceMetrics.h index 92655d21b2..424e5f3f51 100644 --- a/src/core/SkAdvancedTypefaceMetrics.h +++ b/src/core/SkAdvancedTypefaceMetrics.h @@ -28,13 +28,12 @@ public: T* get() const { return fPtr; } T* operator->() const { return fPtr; } - void reset(T* ptr) { + void reset(T* ptr = nullptr) { if (ptr != fPtr) { delete fPtr; fPtr = ptr; } } - void free() { this->reset(nullptr); } T* release() { T* ptr = fPtr; fPtr = nullptr; diff --git a/src/gpu/GrGlyph.h b/src/gpu/GrGlyph.h index 55e925f09d..fb998a4947 100644 --- a/src/gpu/GrGlyph.h +++ b/src/gpu/GrGlyph.h @@ -28,7 +28,7 @@ struct GrGlyph { kCoverage_MaskStyle, kDistance_MaskStyle }; - + typedef uint32_t PackedID; GrBatchAtlas::AtlasID fID; @@ -49,7 +49,7 @@ struct GrGlyph { fTooLargeForAtlas = GrBatchAtlas::GlyphTooLargeForAtlas(bounds.width(), bounds.height()); } - void free() { + void reset() { if (fPath) { delete fPath; fPath = nullptr; @@ -86,7 +86,7 @@ struct GrGlyph { static inline MaskStyle UnpackMaskStyle(PackedID packed) { return ((packed >> 20) & 1) ? kDistance_MaskStyle : kCoverage_MaskStyle; } - + static inline uint16_t UnpackID(PackedID packed) { return (uint16_t)packed; } diff --git a/src/gpu/GrLayerCache.cpp b/src/gpu/GrLayerCache.cpp index c2facbb12d..3c7ab88735 100644 --- a/src/gpu/GrLayerCache.cpp +++ b/src/gpu/GrLayerCache.cpp @@ -98,7 +98,7 @@ GrLayerCache::~GrLayerCache() { SkASSERT(0 == fPictureHash.count()); // The atlas only lets go of its texture when the atlas is deleted. - fAtlas.free(); + fAtlas.reset(); } void GrLayerCache::initAtlas() { diff --git a/src/gpu/text/GrBatchFontCache.cpp b/src/gpu/text/GrBatchFontCache.cpp index d99df1da03..97c55e28ad 100644 --- a/src/gpu/text/GrBatchFontCache.cpp +++ b/src/gpu/text/GrBatchFontCache.cpp @@ -165,7 +165,7 @@ GrBatchTextStrike::GrBatchTextStrike(GrBatchFontCache* cache, const GrFontDescKe GrBatchTextStrike::~GrBatchTextStrike() { SkTDynamicHash<GrGlyph, GrGlyph::PackedID>::Iter iter(&fCache); while (!iter.done()) { - (*iter).free(); + (*iter).reset(); ++iter; } } diff --git a/src/images/SkImageDecoder_libwebp.cpp b/src/images/SkImageDecoder_libwebp.cpp index 52535779fa..2db08cee83 100644 --- a/src/images/SkImageDecoder_libwebp.cpp +++ b/src/images/SkImageDecoder_libwebp.cpp @@ -224,7 +224,7 @@ static bool webp_idecode(SkStream* stream, WebPDecoderConfig* config) { break; } } while (VP8_STATUS_OK != status); - srcStorage.free(); + srcStorage.reset(); WebPIDelete(idec); WebPFreeDecBuffer(&config->output); diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp index 3febc1acb6..6e0dd4b7c7 100644 --- a/src/pdf/SkPDFDevice.cpp +++ b/src/pdf/SkPDFDevice.cpp @@ -732,9 +732,9 @@ SkPDFDevice::~SkPDFDevice() { } void SkPDFDevice::init() { - fContentEntries.free(); + fContentEntries.reset(); fLastContentEntry = nullptr; - fMarginContentEntries.free(); + fMarginContentEntries.reset(); fLastMarginContentEntry = nullptr; fDrawingArea = kContent_DrawingArea; if (fFontGlyphUsage.get() == nullptr) { diff --git a/src/utils/SkBitSet.cpp b/src/utils/SkBitSet.cpp index 3ace15de80..985bb6eed0 100755 --- a/src/utils/SkBitSet.cpp +++ b/src/utils/SkBitSet.cpp @@ -27,7 +27,7 @@ SkBitSet& SkBitSet::operator=(const SkBitSet& rhs) { return *this; } fBitCount = rhs.fBitCount; - fBitData.free(); + fBitData.reset(); fDwordCount = rhs.fDwordCount; fBitData.set(sk_malloc_throw(fDwordCount * sizeof(uint32_t))); memcpy(fBitData.get(), rhs.fBitData.get(), fDwordCount * sizeof(uint32_t)); diff --git a/src/xml/SkDOM.cpp b/src/xml/SkDOM.cpp index 0f0b614f11..8b55f6c980 100644 --- a/src/xml/SkDOM.cpp +++ b/src/xml/SkDOM.cpp @@ -374,7 +374,7 @@ SkXMLParser* SkDOM::beginParsing() { const SkDOM::Node* SkDOM::finishParsing() { SkASSERT(fParser); fRoot = fParser->getRoot(); - fParser.free(); + fParser.reset(); return fRoot; } |