diff options
author | Herb Derby <herb@google.com> | 2017-02-14 15:21:07 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-02-14 22:32:34 +0000 |
commit | 70c60638be6eba5f5b54e0056bc0fd716f086eb0 (patch) | |
tree | ce57f0c614b7676c7459288f3776257b076779ad /src | |
parent | 9df70bb74db8294283e8d2d8e20c95d290d2a34d (diff) |
Move SkDOM to SkArenaAlloc from SkChunkAlloc.
TBR=mtklein@google.com
Change-Id: Icecfc661c9bd4ed03409a132947af0f78784f984
Reviewed-on: https://skia-review.googlesource.com/8401
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Herb Derby <herb@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/xml/SkDOM.cpp | 18 | ||||
-rw-r--r-- | src/xml/SkDOM.h | 4 |
2 files changed, 12 insertions, 10 deletions
diff --git a/src/xml/SkDOM.cpp b/src/xml/SkDOM.cpp index b1cf1d5360..37b230b949 100644 --- a/src/xml/SkDOM.cpp +++ b/src/xml/SkDOM.cpp @@ -48,16 +48,17 @@ struct SkDOMNode { const char* fName; SkDOMNode* fFirstChild; SkDOMNode* fNextSibling; + SkDOMAttr* fAttrs; uint16_t fAttrCount; uint8_t fType; uint8_t fPad; const SkDOMAttr* attrs() const { - return (const SkDOMAttr*)(this + 1); + return fAttrs; } SkDOMAttr* attrs() { - return (SkDOMAttr*)(this + 1); + return fAttrs; } }; @@ -175,17 +176,17 @@ const char* SkDOM::AttrIter::next(const char** value) { #include "SkXMLParser.h" #include "SkTDArray.h" -static char* dupstr(SkChunkAlloc* chunk, const char src[]) { +static char* dupstr(SkArenaAlloc* chunk, const char src[]) { SkASSERT(chunk && src); size_t len = strlen(src); - char* dst = (char*)chunk->alloc(len + 1, SkChunkAlloc::kThrow_AllocFailType); + char* dst = chunk->makeArrayDefault<char>(len + 1); memcpy(dst, src, len + 1); return dst; } class SkDOMParser : public SkXMLParser { public: - SkDOMParser(SkChunkAlloc* chunk) : SkXMLParser(&fParserError), fAlloc(chunk) { + SkDOMParser(SkArenaAlloc* chunk) : SkXMLParser(&fParserError), fAlloc(chunk) { fAlloc->reset(); fRoot = nullptr; fLevel = 0; @@ -200,12 +201,13 @@ protected: int attrCount = fAttrs.count(); - SkDOM::Node* node = (SkDOM::Node*)fAlloc->alloc(sizeof(SkDOM::Node) + attrCount * sizeof(SkDOM::Attr), - SkChunkAlloc::kThrow_AllocFailType); + SkDOMAttr* attrs = fAlloc->makeArrayDefault<SkDOMAttr>(attrCount); + SkDOM::Node* node = fAlloc->make<SkDOM::Node>(); node->fName = fElemName; node->fFirstChild = nullptr; node->fAttrCount = SkToU16(attrCount); + node->fAttrs = attrs; node->fType = fElemType; if (fRoot == nullptr) { @@ -278,7 +280,7 @@ private: } SkTDArray<SkDOM::Node*> fParentStack; - SkChunkAlloc* fAlloc; + SkArenaAlloc* fAlloc; SkDOM::Node* fRoot; bool fNeedToFlush; diff --git a/src/xml/SkDOM.h b/src/xml/SkDOM.h index 0ffb04232a..e72bcadea8 100644 --- a/src/xml/SkDOM.h +++ b/src/xml/SkDOM.h @@ -8,8 +8,8 @@ #ifndef SkDOM_DEFINED #define SkDOM_DEFINED -#include "../private/SkChunkAlloc.h" #include "../private/SkTemplates.h" +#include "SkArenaAlloc.h" #include "SkScalar.h" #include "SkTypes.h" @@ -84,7 +84,7 @@ public: }; private: - SkChunkAlloc fAlloc; + SkArenaAlloc fAlloc; Node* fRoot; std::unique_ptr<SkDOMParser> fParser; |