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

Side by Side Diff: base/memory/free_deleter.h

Issue 1837483003: Move base::FreeDeleter into its own header. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef BASE_MEMORY_FREE_DELETER_H_
6 #define BASE_MEMORY_FREE_DELETER_H_
7
8 #include <stdlib.h>
9
10 namespace base {
11
12 // Function object which invokes 'free' on its parameter, which must be
13 // a pointer. Can be used to store malloc-allocated pointers in std::unique_ptr:
14 //
15 // std::unique_ptr<int, base::FreeDeleter> foo_ptr(
16 // static_cast<int*>(malloc(sizeof(int))));
17 struct FreeDeleter {
18 inline void operator()(void* ptr) const {
19 free(ptr);
20 }
21 };
22
23 } // namespace base
24
25 #endif // BASE_MEMORY_FREE_DELETER_H_
OLDNEW
« no previous file with comments | « base/file_version_info_win.h ('k') | base/memory/scoped_ptr.h » ('j') | base/memory/scoped_ptr.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698