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

Unified Diff: tools/skdiff_utils.cpp

Issue 565803005: use SkData::NewUninitialized (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: readInData -> NewFromStream Created 6 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 | « tools/lua/lua_pictures.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/skdiff_utils.cpp
diff --git a/tools/skdiff_utils.cpp b/tools/skdiff_utils.cpp
index 14a9fec7e4a126c6bfaf6d7998fbd8a442f3a8f1..a00ea7b567b3bb3ac158f673c858b1418f892b4b 100644
--- a/tools/skdiff_utils.cpp
+++ b/tools/skdiff_utils.cpp
@@ -25,27 +25,11 @@ bool are_buffers_equal(SkData* skdata1, SkData* skdata2) {
}
SkData* read_file(const char* file_path) {
- SkFILEStream fileStream(file_path);
- if (!fileStream.isValid()) {
+ SkData* data = SkData::NewFromFileName(file_path);
+ if (!data) {
SkDebugf("WARNING: could not open file <%s> for reading\n", file_path);
- return NULL;
}
- size_t bytesInFile = fileStream.getLength();
- size_t bytesLeftToRead = bytesInFile;
-
- void* bufferStart = sk_malloc_throw(bytesInFile);
- char* bufferPointer = (char*)bufferStart;
- while (bytesLeftToRead > 0) {
- size_t bytesReadThisTime = fileStream.read(bufferPointer, bytesLeftToRead);
- if (0 == bytesReadThisTime) {
- SkDebugf("WARNING: error reading from <%s>\n", file_path);
- sk_free(bufferStart);
- return NULL;
- }
- bytesLeftToRead -= bytesReadThisTime;
- bufferPointer += bytesReadThisTime;
- }
- return SkData::NewFromMalloc(bufferStart, bytesInFile);
+ return data;
}
bool get_bitmap(SkData* fileBits, DiffResource& resource, SkImageDecoder::Mode mode) {
« no previous file with comments | « tools/lua/lua_pictures.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698