Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Unified Diff: src/core/SkRWBuffer.cpp

Issue 2385803002: Add a SkRWBuffer reserve mechanism (Closed)
Patch Set: missed the initial allocation Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkRWBuffer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkRWBuffer.cpp
diff --git a/src/core/SkRWBuffer.cpp b/src/core/SkRWBuffer.cpp
index 07a537a640a27173bea2093614bef8a468db0d01..b8dffa7bf329864ab4dcae2f2fc3511b38d29b14 100644
--- a/src/core/SkRWBuffer.cpp
+++ b/src/core/SkRWBuffer.cpp
@@ -194,7 +194,7 @@ SkRWBuffer::~SkRWBuffer() {
// next, since our reader will be using fCapacity (min'd against its total available) to know how
// many bytes to read from a given block.
//
-void SkRWBuffer::append(const void* src, size_t length) {
+void SkRWBuffer::append(const void* src, size_t length, size_t reserve) {
this->validate();
if (0 == length) {
return;
@@ -203,7 +203,7 @@ void SkRWBuffer::append(const void* src, size_t length) {
fTotalUsed += length;
if (nullptr == fHead) {
- fHead = SkBufferHead::Alloc(length);
+ fHead = SkBufferHead::Alloc(length + reserve);
fTail = &fHead->fBlock;
}
@@ -213,7 +213,7 @@ void SkRWBuffer::append(const void* src, size_t length) {
length -= written;
if (length) {
- SkBufferBlock* block = SkBufferBlock::Alloc(length);
+ SkBufferBlock* block = SkBufferBlock::Alloc(length + reserve);
fTail->fNext = block;
fTail = block;
written = fTail->append(src, length);
« no previous file with comments | « include/core/SkRWBuffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698