| Index: include/core/SkTemplates.h
|
| diff --git a/include/core/SkTemplates.h b/include/core/SkTemplates.h
|
| index b18556b4524b8bb713b25747ff51929a97a8998e..b087a5a9c9cae949cf179f4b9eccf434bef8add5 100644
|
| --- a/include/core/SkTemplates.h
|
| +++ b/include/core/SkTemplates.h
|
| @@ -437,7 +437,7 @@ public:
|
| sk_free(fPtr);
|
| }
|
| if (count > N) {
|
| - fPtr = (T*)sk_malloc_flags(count * sizeof(T), SK_MALLOC_THROW | SK_MALLOC_TEMP);
|
| + fPtr = (T*)sk_malloc_throw(count * sizeof(T));
|
| } else if (count) {
|
| fPtr = fTStorage;
|
| } else {
|
| @@ -464,6 +464,22 @@ public:
|
| return fPtr[index];
|
| }
|
|
|
| + // Reallocs the array, can be used to shrink the allocation. Makes no attempt to be intelligent
|
| + void realloc(size_t count) {
|
| + if (count > N) {
|
| + if (fPtr == fTStorage) {
|
| + fPtr = (T*)sk_malloc_throw(count * sizeof(T));
|
| + memcpy(fPtr, fTStorage, N * sizeof(T));
|
| + } else {
|
| + fPtr = (T*)sk_realloc_throw(fPtr, count * sizeof(T));
|
| + }
|
| + } else if (!fPtr) {
|
| + fPtr = fTStorage;
|
| + } else if (fPtr != fTStorage) {
|
| + fPtr = (T*)sk_realloc_throw(fPtr, count * sizeof(T));
|
| + }
|
| + }
|
| +
|
| private:
|
| T* fPtr;
|
| union {
|
|
|