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

Unified Diff: src/core/SkStream.cpp

Issue 2339273002: SkFontData to use smart pointers. (Closed)
Patch Set: Add trivial bodies to the trivial implementations. 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 | « src/core/SkFontMgr.cpp ('k') | src/core/SkTypeface.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkStream.cpp
diff --git a/src/core/SkStream.cpp b/src/core/SkStream.cpp
index 48eb92cae5c5631c1e4546f95e471040fa2297e9..e7b3a7a7e5777ff40de437a8628a441921b1b259 100644
--- a/src/core/SkStream.cpp
+++ b/src/core/SkStream.cpp
@@ -10,6 +10,7 @@
#include "SkStreamPriv.h"
#include "SkData.h"
#include "SkFixed.h"
+#include "SkMakeUnique.h"
#include "SkString.h"
#include "SkOSFile.h"
#include "SkTypes.h"
@@ -854,20 +855,18 @@ static sk_sp<SkData> mmap_filename(const char path[]) {
return data;
}
-SkStreamAsset* SkStream::NewFromFile(const char path[]) {
+std::unique_ptr<SkStreamAsset> SkStream::MakeFromFile(const char path[]) {
auto data(mmap_filename(path));
if (data) {
- return new SkMemoryStream(std::move(data));
+ return skstd::make_unique<SkMemoryStream>(std::move(data));
}
- // If we get here, then our attempt at using mmap failed, so try normal
- // file access.
- SkFILEStream* stream = new SkFILEStream(path);
+ // If we get here, then our attempt at using mmap failed, so try normal file access.
+ auto stream = skstd::make_unique<SkFILEStream>(path);
if (!stream->isValid()) {
- delete stream;
- stream = nullptr;
+ return nullptr;
}
- return stream;
+ return std::move(stream);
}
// Declared in SkStreamPriv.h:
« no previous file with comments | « src/core/SkFontMgr.cpp ('k') | src/core/SkTypeface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698