aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-03-21 17:38:49 +0000
committerGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-03-21 17:38:49 +0000
commit35300c47fc6e59d8415a06042f230ed36deb60b3 (patch)
tree100dd9b3b070d4e71298b95cb8c75f2093719524
parent38c37ddbaf3b29cdacbc25d4aa2acca1869d276f (diff)
Fix minor valgrind-found memory leaks
-rw-r--r--src/core/SkRefDict.cpp1
-rw-r--r--src/effects/SkMatrixConvolutionImageFilter.cpp7
-rw-r--r--tests/Matrix44Test.cpp2
-rw-r--r--tests/PDFPrimitivesTest.cpp2
4 files changed, 7 insertions, 5 deletions
diff --git a/src/core/SkRefDict.cpp b/src/core/SkRefDict.cpp
index 50a469dfc7..44eddf01a9 100644
--- a/src/core/SkRefDict.cpp
+++ b/src/core/SkRefDict.cpp
@@ -59,6 +59,7 @@ void SkRefDict::set(const char name[], SkRefCnt* data) {
} else {
fImpl = rec->fNext;
}
+ delete rec;
}
return;
}
diff --git a/src/effects/SkMatrixConvolutionImageFilter.cpp b/src/effects/SkMatrixConvolutionImageFilter.cpp
index c4cffeafab..b25979ca8d 100644
--- a/src/effects/SkMatrixConvolutionImageFilter.cpp
+++ b/src/effects/SkMatrixConvolutionImageFilter.cpp
@@ -539,9 +539,9 @@ GrEffectRef* GrMatrixConvolutionEffect::TestCreate(SkMWCRandom* random,
int width = random->nextRangeU(1, MAX_KERNEL_SIZE);
int height = random->nextRangeU(1, MAX_KERNEL_SIZE / width);
SkISize kernelSize = SkISize::Make(width, height);
- SkScalar* kernel = new SkScalar[width * height];
+ SkAutoTDeleteArray<SkScalar> kernel(new SkScalar[width * height]);
for (int i = 0; i < width * height; i++) {
- kernel[i] = random->nextSScalar1();
+ kernel.get()[i] = random->nextSScalar1();
}
SkScalar gain = random->nextSScalar1();
SkScalar bias = random->nextSScalar1();
@@ -551,13 +551,12 @@ GrEffectRef* GrMatrixConvolutionEffect::TestCreate(SkMWCRandom* random,
bool convolveAlpha = random->nextBool();
return GrMatrixConvolutionEffect::Create(textures[texIdx],
kernelSize,
- kernel,
+ kernel.get(),
gain,
bias,
target,
tileMode,
convolveAlpha);
-
}
bool SkMatrixConvolutionImageFilter::asNewEffect(GrEffectRef** effect,
diff --git a/tests/Matrix44Test.cpp b/tests/Matrix44Test.cpp
index 269e359022..bdeafd4ff9 100644
--- a/tests/Matrix44Test.cpp
+++ b/tests/Matrix44Test.cpp
@@ -80,6 +80,8 @@ static bool bits_isonly(int value, int mask) {
static void test_constructor(skiatest::Reporter* reporter) {
// Allocate a matrix on the heap
SkMatrix44* placeholderMatrix = new SkMatrix44();
+ SkAutoTDelete<SkMatrix44> deleteMe(placeholderMatrix);
+
for (int row = 0; row < 4; ++row) {
for (int col = 0; col < 4; ++col) {
placeholderMatrix->setDouble(row, col, row * col);
diff --git a/tests/PDFPrimitivesTest.cpp b/tests/PDFPrimitivesTest.cpp
index cc89d6b806..7f6bc3485d 100644
--- a/tests/PDFPrimitivesTest.cpp
+++ b/tests/PDFPrimitivesTest.cpp
@@ -225,7 +225,7 @@ static void TestSubstitute(skiatest::Reporter* reporter) {
// and there is no assert on input data in Debug mode.
static void test_issue1083() {
SkISize pageSize = SkISize::Make(100, 100);
- SkPDFDevice* dev = new SkPDFDevice(pageSize, pageSize, SkMatrix::I());
+ SkAutoTUnref<SkPDFDevice> dev(new SkPDFDevice(pageSize, pageSize, SkMatrix::I()));
SkCanvas c(dev);
SkPaint paint;