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

Unified Diff: base/file_util.h

Issue 168643002: Convert scoped_ptr_malloc -> scoped_ptr, part 1. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | « base/debug/stack_trace_posix.cc ('k') | base/file_version_info_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/file_util.h
diff --git a/base/file_util.h b/base/file_util.h
index 8c37639d1cc1a8e0c51cbcff3c263d6a20c34a1b..7690703b8128b106c7ed90dcbe5b43e50ce48a16 100644
--- a/base/file_util.h
+++ b/base/file_util.h
@@ -391,22 +391,20 @@ BASE_EXPORT bool VerifyPathControlledByAdmin(const base::FilePath& path);
// the directory |path|, in the number of FilePath::CharType, or -1 on failure.
BASE_EXPORT int GetMaximumPathComponentLength(const base::FilePath& path);
-// A class to handle auto-closing of FILE*'s.
-class ScopedFILEClose {
- public:
+// Functor for |ScopedFILE| (below).
+struct ScopedFILEClose {
inline void operator()(FILE* x) const {
- if (x) {
+ if (x)
fclose(x);
- }
}
};
-typedef scoped_ptr_malloc<FILE, ScopedFILEClose> ScopedFILE;
+// Automatically closes |FILE*|s.
+typedef scoped_ptr<FILE, ScopedFILEClose> ScopedFILE;
#if defined(OS_POSIX)
-// A class to handle auto-closing of FDs.
-class ScopedFDClose {
- public:
+// Functor for |ScopedFD| (below).
+struct ScopedFDClose {
inline void operator()(int* x) const {
if (x && *x >= 0) {
if (IGNORE_EINTR(close(*x)) < 0)
@@ -415,7 +413,11 @@ class ScopedFDClose {
}
};
-typedef scoped_ptr_malloc<int, ScopedFDClose> ScopedFD;
+// Automatically closes FDs (note: doesn't store the FD).
+// TODO(viettrungluu): This is a very odd API, since (unlike |FILE*|s, you'll
+// need to store the FD separately and keep its memory alive). This should
+// probably be called |ScopedFDCloser| or something like that.
+typedef scoped_ptr<int, ScopedFDClose> ScopedFD;
#endif // OS_POSIX
#if defined(OS_LINUX)
« no previous file with comments | « base/debug/stack_trace_posix.cc ('k') | base/file_version_info_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698