remove SkRefCnt safeRef() and safeUnref(), and replace the call-sites with
authorreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 7 Feb 2011 15:30:46 +0000 (15:30 +0000)
committerreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 7 Feb 2011 15:30:46 +0000 (15:30 +0000)
commit82065d667f64e232bcde2ad849756a6096fcbe6f
treeb286676278e48522d5a1e153ff5696d3f2088cc8
parent18908aacf360eaacf5e6a98dd57342adb98cf463
remove SkRefCnt safeRef() and safeUnref(), and replace the call-sites with
SkSafeRef() and SkSafeUnref().

This is basically a bug waiting to happen. An optimizing compiler can remove
checks for null on "this" if it chooses. However, SkRefCnt::safeRef() relies on
precisely this check...

void SkRefCnt::safeRef() {
    if (this) {
        this->ref();
    }
}

Since a compiler might skip the if-clause, it breaks the intention of this
method, hence its removal.

static inline void SkSafeRef(SkRefCnt* obj) {
    if (obj) {
        obj->ref();
    }
}

This form is not ignored by an optimizing compile, so we use it instead.

git-svn-id: http://skia.googlecode.com/svn/trunk@762 2bbb7eff-a529-9590-31e7-b0007b416f81
38 files changed:
include/core/SkRefCnt.h
samplecode/SampleDrawLooper.cpp
samplecode/SampleFontScalerTest.cpp
samplecode/SampleMovie.cpp
samplecode/SamplePatch.cpp
samplecode/SampleShaders.cpp
samplecode/SampleText.cpp
samplecode/SampleTextEffects.cpp
samplecode/SampleTypeface.cpp
samplecode/SampleVertices.cpp
src/animator/SkDrawExtraPathEffect.cpp
src/animator/SkDrawPaint.cpp
src/core/SkBitmap.cpp
src/core/SkBlitter.cpp
src/core/SkBlitter_4444.cpp
src/core/SkBlitter_A8.cpp
src/core/SkBlitter_ARGB32.cpp
src/core/SkCanvas.cpp
src/core/SkComposeShader.cpp
src/core/SkDraw.cpp
src/core/SkFlattenable.cpp
src/core/SkMallocPixelRef.cpp
src/core/SkPaint.cpp
src/core/SkPicture.cpp
src/core/SkPicturePlayback.cpp
src/core/SkPictureRecord.cpp
src/core/SkScalerContext.cpp
src/core/SkSpriteBlitter_ARGB32.cpp
src/effects/SkBlurDrawLooper.cpp
src/effects/SkGradientShader.cpp
src/effects/SkLayerRasterizer.cpp
src/images/SkImageDecoder.cpp
src/images/SkImageRef.cpp
src/pdf/SkPDFPage.cpp
src/pdf/SkPDFTypes.cpp
src/utils/SkDumpCanvas.cpp
src/utils/SkProxyCanvas.cpp
tests/Test.cpp