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

Unified Diff: include/core/SkFlattenableBuffers.h

Issue 37803002: Adding size parameter to read array functions (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fixed comments and added test Created 7 years, 2 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 | « gyp/tests.gyp ('k') | src/core/SkColorTable.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkFlattenableBuffers.h
diff --git a/include/core/SkFlattenableBuffers.h b/include/core/SkFlattenableBuffers.h
index 6e44550be561c6f267ade5f6655557a03d2edb3f..5a06211026f59e4c76156581bd4f5dfc51248894 100644
--- a/include/core/SkFlattenableBuffers.h
+++ b/include/core/SkFlattenableBuffers.h
@@ -99,11 +99,22 @@ public:
virtual void readPath(SkPath* path) = 0;
// binary data and arrays
- virtual uint32_t readByteArray(void* value) = 0;
- virtual uint32_t readColorArray(SkColor* colors) = 0;
- virtual uint32_t readIntArray(int32_t* values) = 0;
- virtual uint32_t readPointArray(SkPoint* points) = 0;
- virtual uint32_t readScalarArray(SkScalar* values) = 0;
+
+ /**
+ * In the following read.*Array(...) functions, the size parameter specifies the allocation
+ * size (in bytes) of the pointer parameter. In the case where isValidating() is true, then
+ * if the pointer parameter's size does not match the size to be read, the pointer
+ * parameter's memory will then stay uninitialized, the cursor will not move, the function
+ * will return 0 and an error flag will be set internally (see SkValidatingReadBuffer).
+ * If the sizes match, then the amount of memory actually read will be returned.
+ * If isValidating() is false, then the size parameter is used as the maximum amount of memory
reed1 2013/10/30 14:50:30 It seems like we're saying the following: if we'r
sugoi1 2013/10/30 17:43:51 Done.
+ * that can be read and at most this much memory will be read.
+ */
+ virtual size_t readByteArray(void* value, size_t size) = 0;
+ virtual size_t readColorArray(SkColor* colors, size_t size) = 0;
+ virtual size_t readIntArray(int32_t* values, size_t size) = 0;
+ virtual size_t readPointArray(SkPoint* points, size_t size) = 0;
+ virtual size_t readScalarArray(SkScalar* values, size_t size) = 0;
/** This helper peeks into the buffer and reports back the length of the next array in
* the buffer but does not change the state of the buffer.
@@ -127,7 +138,7 @@ public:
SkData* readByteArrayAsData() {
size_t len = this->getArrayCount();
void* buffer = sk_malloc_throw(len);
- (void)this->readByteArray(buffer);
+ (void)this->readByteArray(buffer, len);
return SkData::NewFromMalloc(buffer, len);
}
« no previous file with comments | « gyp/tests.gyp ('k') | src/core/SkColorTable.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698