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: |