summaryrefslogtreecommitdiff
path: root/libs/hwui/GradientCache.h
diff options
context:
space:
mode:
author Chris Craik <ccraik@google.com> 2014-12-22 17:16:56 -0800
committer Chris Craik <ccraik@google.com> 2014-12-23 16:53:56 -0800
commit51d6a3db97bdd5315f1a17a4b447d10a92217b98 (patch)
tree80803f8d2a5507e2d29bd58c7243a23fca343454 /libs/hwui/GradientCache.h
parente84a208317e0ed388fcdad1e6743c7849acb51b0 (diff)
Cleanup various clang warnings, use unique_ptrs in several places
Change-Id: I347904b25e51fcc7de14b1e72f1acd0f6ba26f3f
Diffstat (limited to 'libs/hwui/GradientCache.h')
-rw-r--r--libs/hwui/GradientCache.h24
1 files changed, 8 insertions, 16 deletions
diff --git a/libs/hwui/GradientCache.h b/libs/hwui/GradientCache.h
index ef4e0cd72873..9176c763a65d 100644
--- a/libs/hwui/GradientCache.h
+++ b/libs/hwui/GradientCache.h
@@ -42,20 +42,12 @@ struct GradientCacheEntry {
}
GradientCacheEntry(const GradientCacheEntry& entry) {
- copy(entry.colors, entry.positions, entry.count);
- }
-
- ~GradientCacheEntry() {
- delete[] colors;
- delete[] positions;
+ copy(entry.colors.get(), entry.positions.get(), entry.count);
}
GradientCacheEntry& operator=(const GradientCacheEntry& entry) {
if (this != &entry) {
- delete[] colors;
- delete[] positions;
-
- copy(entry.colors, entry.positions, entry.count);
+ copy(entry.colors.get(), entry.positions.get(), entry.count);
}
return *this;
@@ -73,18 +65,18 @@ struct GradientCacheEntry {
return compare(*this, other) != 0;
}
- uint32_t* colors;
- float* positions;
+ std::unique_ptr<uint32_t[]> colors;
+ std::unique_ptr<float[]> positions;
uint32_t count;
private:
void copy(uint32_t* colors, float* positions, uint32_t count) {
this->count = count;
- this->colors = new uint32_t[count];
- this->positions = new float[count];
+ this->colors.reset(new uint32_t[count]);
+ this->positions.reset(new float[count]);
- memcpy(this->colors, colors, count * sizeof(uint32_t));
- memcpy(this->positions, positions, count * sizeof(float));
+ memcpy(this->colors.get(), colors, count * sizeof(uint32_t));
+ memcpy(this->positions.get(), positions, count * sizeof(float));
}
}; // GradientCacheEntry