aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar halcanary <halcanary@google.com>2016-09-19 10:27:03 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-09-19 10:27:03 -0700
commite202bd8b71f6aa184c2c8ce6f653755de1331c88 (patch)
tree416db148b602338f9b1444373571ec48e60143d7
parent88987d83d70654042f7c34f1a92bfd2b8edbe482 (diff)
SkPDF: SkBitSet gets reset() to make drop() better.
-rw-r--r--src/pdf/SkPDFFont.cpp2
-rw-r--r--src/utils/SkBitSet.h6
2 files changed, 6 insertions, 2 deletions
diff --git a/src/pdf/SkPDFFont.cpp b/src/pdf/SkPDFFont.cpp
index 89c7951f63..682f721c26 100644
--- a/src/pdf/SkPDFFont.cpp
+++ b/src/pdf/SkPDFFont.cpp
@@ -727,5 +727,7 @@ bool SkPDFFont::CanEmbedTypeface(SkTypeface* typeface, SkPDFCanon* canon) {
void SkPDFFont::drop() {
fTypeface = nullptr;
+ fGlyphUsage.~SkBitSet();
+ new (&fGlyphUsage) SkBitSet(0);
this->SkPDFDict::drop();
}
diff --git a/src/utils/SkBitSet.h b/src/utils/SkBitSet.h
index a8585a20b9..2e2dbebbb2 100644
--- a/src/utils/SkBitSet.h
+++ b/src/utils/SkBitSet.h
@@ -14,9 +14,11 @@
class SkBitSet {
public:
explicit SkBitSet(int numberOfBits) {
- SkASSERT(numberOfBits > 0);
+ SkASSERT(numberOfBits >= 0);
fDwordCount = (numberOfBits + 31) / 32; // Round up size to 32-bit boundary.
- fBitData.reset((uint32_t*)sk_calloc_throw(fDwordCount * sizeof(uint32_t)));
+ if (fDwordCount > 0) {
+ fBitData.reset((uint32_t*)sk_calloc_throw(fDwordCount * sizeof(uint32_t)));
+ }
}
SkBitSet(const SkBitSet&) = delete;