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

Unified Diff: sandbox/linux/bpf_dsl/cons.h

Issue 1892783002: bpf_dsl: replace scoped_refptr with std::shared_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix asan build Created 4 years, 8 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 | « sandbox/linux/bpf_dsl/bpf_dsl_impl.h ('k') | sandbox/linux/seccomp-bpf-helpers/baseline_policy.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sandbox/linux/bpf_dsl/cons.h
diff --git a/sandbox/linux/bpf_dsl/cons.h b/sandbox/linux/bpf_dsl/cons.h
index be050f77817eef4bd4f7a4b228a00a6c789b7fef..07ac3dfc23d3855b322fb937382d71bbc17832d4 100644
--- a/sandbox/linux/bpf_dsl/cons.h
+++ b/sandbox/linux/bpf_dsl/cons.h
@@ -5,8 +5,9 @@
#ifndef SANDBOX_LINUX_BPF_DSL_CONS_H_
#define SANDBOX_LINUX_BPF_DSL_CONS_H_
+#include <memory>
+
#include "base/macros.h"
-#include "base/memory/ref_counted.h"
#include "sandbox/sandbox_export.h"
namespace sandbox {
@@ -60,19 +61,19 @@ class ListIterator;
// List represents a (possibly null) pointer to a cons cell.
template <typename T>
-using List = scoped_refptr<const Cell<T>>;
+using List = std::shared_ptr<const Cell<T>>;
// Cons extends a cons list by prepending a new value to the front.
template <typename T>
-List<T> Cons(const T& head, const List<T>& tail) {
- return List<T>(new const Cell<T>(head, tail));
+List<T> Cons(const T& head, List<T> tail) {
+ return std::make_shared<Cell<T>>(head, std::move(tail));
}
// Cell represents an individual "cons cell" within a cons list.
template <typename T>
-class Cell : public base::RefCounted<Cell<T>> {
+class Cell {
public:
- Cell(const T& head, const List<T>& tail) : head_(head), tail_(tail) {}
+ Cell(const T& head, List<T> tail) : head_(head), tail_(std::move(tail)) {}
// Head returns this cell's head element.
const T& head() const { return head_; }
@@ -81,12 +82,9 @@ class Cell : public base::RefCounted<Cell<T>> {
const List<T>& tail() const { return tail_; }
private:
- virtual ~Cell() {}
-
T head_;
List<T> tail_;
- friend class base::RefCounted<Cell<T>>;
DISALLOW_COPY_AND_ASSIGN(Cell);
};
« no previous file with comments | « sandbox/linux/bpf_dsl/bpf_dsl_impl.h ('k') | sandbox/linux/seccomp-bpf-helpers/baseline_policy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698