SkAuto[S]TMalloc only for trivially constructible/destructible.
Prevents introduction of a bug when modifying a type that is used
with one of these containers in such way that makes the use
unsafe.
Change-Id: I959e6f3bfbc9664a6b0ced636f5ae6cbe72eee1a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/390676
Reviewed-by: Herb Derby <herb@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/samplecode/SamplePathText.cpp b/samplecode/SamplePathText.cpp
index b8927b9..97c4c26 100644
--- a/samplecode/SamplePathText.cpp
+++ b/samplecode/SamplePathText.cpp
@@ -170,7 +170,7 @@
// Get valid front data.
fBackgroundAnimationTask.wait();
this->runAnimationTask(0, 0, screenWidth, screenHeight);
- memcpy(fFrontMatrices, fBackMatrices, kNumPaths * sizeof(SkMatrix));
+ std::copy_n(fBackMatrices.get(), kNumPaths, fFrontMatrices.get());
fLastTick = 0;
}
@@ -241,8 +241,8 @@
};
Velocity fVelocities[kNumPaths];
- SkAutoTMalloc<SkMatrix> fFrontMatrices;
- SkAutoTMalloc<SkMatrix> fBackMatrices;
+ SkAutoTArray<SkMatrix> fFrontMatrices;
+ SkAutoTArray<SkMatrix> fBackMatrices;
SkTaskGroup fBackgroundAnimationTask;
double fLastTick;
};