Update SkTDict to use SkArenaAlloc.

Change-Id: I7ac33faa59bcad25b0580193af965a8525eb18e7
Reviewed-on: https://skia-review.googlesource.com/7360
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Mike Klein <mtklein@chromium.org>
This commit is contained in:
Herb Derby 2017-01-20 16:58:06 -05:00 committed by Skia Commit-Bot
parent 77a86f81f3
commit 2a0daee1af
2 changed files with 7 additions and 3 deletions

View File

@ -8,7 +8,7 @@
#ifndef SkTDict_DEFINED
#define SkTDict_DEFINED
#include "SkChunkAlloc.h"
#include "SkArenaAlloc.h"
#include "SkTSearch.h"
#include "SkTDArray.h"
@ -37,7 +37,7 @@ public:
return false;
} else {
Pair* pair = fArray.insert(~index);
char* copy = (char*)fStrings.alloc(len + 1, SkChunkAlloc::kThrow_AllocFailType);
char* copy = fStrings.makeArrayDefault<char>(len + 1);
memcpy(copy, name, len);
copy[len] = '\0';
pair->fName = copy;
@ -123,7 +123,7 @@ public:
private:
SkTDArray<Pair> fArray;
SkChunkAlloc fStrings;
SkArenaAlloc fStrings;
int find_index(const char name[]) const {
return find_index(name, strlen(name));

View File

@ -60,6 +60,10 @@ public:
: SkArenaAlloc(block, kSize, extraSize)
{}
SkArenaAlloc(size_t extraSize)
: SkArenaAlloc(nullptr, 0, extraSize)
{}
~SkArenaAlloc();
template <typename T, typename... Args>