| Index: src/core/SkWriter32.cpp
|
| diff --git a/src/core/SkWriter32.cpp b/src/core/SkWriter32.cpp
|
| index 0de8b20b250addf9059334a225aae0b5d5339fc1..72fa8701c67116b2b85fce286aa37560a546ecd9 100644
|
| --- a/src/core/SkWriter32.cpp
|
| +++ b/src/core/SkWriter32.cpp
|
| @@ -8,6 +8,7 @@
|
| #include "SkReader32.h"
|
| #include "SkString.h"
|
| #include "SkWriter32.h"
|
| +#include "SkData.h"
|
|
|
| /*
|
| * Strings are stored as: length[4-bytes] + string_data + '\0' + pad_to_mul_4
|
| @@ -84,3 +85,20 @@ void SkWriter32::growToAtLeast(size_t size) {
|
| SkASSERT(fInternal.count() == fCapacity);
|
| SkASSERT(fInternal.reserved() == fCapacity);
|
| }
|
| +
|
| +SkData* SkWriter32::release() {
|
| + uint8_t* buffer = NULL;
|
| + if ((fExternal != NULL) && (fData == fExternal)) {
|
| + // We need to copy to an allocated buffer before returning.
|
| + buffer = (uint8_t*)sk_malloc_throw(fUsed);
|
| + memcpy(buffer, fData, fUsed);
|
| + } else {
|
| + buffer = fInternal.detach();
|
| + }
|
| + SkData* data = SkData::NewFromMalloc(buffer, fUsed);
|
| + fData = NULL;
|
| + fCapacity = 0;
|
| + fUsed = 0;
|
| + fExternal = NULL;
|
| + return data;
|
| +}
|
|
|