about summary refs log tree commit diff
path: root/third_party
diff options
context:
space:
mode:
Diffstat (limited to 'third_party')
-rw-r--r--third_party/nix/src/libexpr/eval.cc12
-rw-r--r--third_party/nix/src/libexpr/eval.hh2
-rw-r--r--third_party/nix/src/libexpr/primops.cc8
-rw-r--r--third_party/nix/src/libexpr/value.hh2
4 files changed, 12 insertions, 12 deletions
diff --git a/third_party/nix/src/libexpr/eval.cc b/third_party/nix/src/libexpr/eval.cc
index 28ae46bdfd8c..2a0aba1a4c8b 100644
--- a/third_party/nix/src/libexpr/eval.cc
+++ b/third_party/nix/src/libexpr/eval.cc
@@ -598,15 +598,15 @@ Env& EvalState::allocEnv(size_t size) {
   return *env;
 }
 
-void EvalState::mkList(Value& v, NixList* list) {
+void EvalState::mkList(Value& v, std::shared_ptr<NixList> list) {
+  nrListElems += list->size();
   clearValue(v);
   v.type = tList;
   v.list = list;
-  nrListElems += list->size();
 }
 
 void EvalState::mkList(Value& v, size_t size) {
-  EvalState::mkList(v, new NixList(size));
+  EvalState::mkList(v, std::make_shared<NixList>(size));
 }
 
 unsigned long nrThunks = 0;
@@ -1224,7 +1224,7 @@ void ExprOpConcatLists::eval(EvalState& state, Env& env, Value& v) {
 void EvalState::concatLists(Value& v, const NixList& lists, const Pos& pos) {
   nrListConcats++;
 
-  auto outlist = new NixList();
+  auto outlist = std::make_shared<NixList>();
 
   for (Value* list : lists) {
     forceList(*list, pos);
@@ -1816,8 +1816,8 @@ size_t valueSize(const Value& v) {
         }
         break;
       case tList:
-        if (seenLists.find(v.list) == seenLists.end()) {
-          seenLists.insert(v.list);
+        if (seenLists.find(v.list.get()) == seenLists.end()) {
+          seenLists.insert(v.list.get());
           sz += v.listSize() * sizeof(Value*);
           for (const Value* v : *v.list) {
             sz += doValue(*v);
diff --git a/third_party/nix/src/libexpr/eval.hh b/third_party/nix/src/libexpr/eval.hh
index f36d11b92b99..0352a89a2ab8 100644
--- a/third_party/nix/src/libexpr/eval.hh
+++ b/third_party/nix/src/libexpr/eval.hh
@@ -258,7 +258,7 @@ class EvalState {
   Value* allocAttr(Value& vAttrs, const Symbol& name);
 
   // Create a list value from the specified vector.
-  void mkList(Value& v, NixList* list);
+  void mkList(Value& v, std::shared_ptr<NixList> list);
 
   // Create a list value, allocating as many elements as specified in
   // size. This is used for the many cases in this codebase where
diff --git a/third_party/nix/src/libexpr/primops.cc b/third_party/nix/src/libexpr/primops.cc
index dd8a509df32d..761ff954a433 100644
--- a/third_party/nix/src/libexpr/primops.cc
+++ b/third_party/nix/src/libexpr/primops.cc
@@ -1603,7 +1603,7 @@ static void prim_sort(EvalState& state, const Pos& pos, Value** args,
 
   // Copy of the input list which can be sorted in place.
   v.type = tList;
-  v.list = new NixList(*args[1]->list);
+  v.list = std::make_shared<NixList>(*args[1]->list);
 
   std::for_each(v.list->begin(), v.list->end(),
                 [&](Value* val) { state.forceValue(*val); });
@@ -1633,8 +1633,8 @@ static void prim_partition(EvalState& state, const Pos& pos, Value** args,
   state.forceFunction(*args[0], pos);
   state.forceList(*args[1], pos);
 
-  NixList* right = new NixList();
-  NixList* wrong = new NixList();
+  std::shared_ptr<NixList> right = std::make_shared<NixList>();
+  std::shared_ptr<NixList> wrong = std::make_shared<NixList>();
 
   for (Value* elem : *args[1]->list) {
     state.forceValue(*elem, pos);
@@ -1664,7 +1664,7 @@ static void prim_concatMap(EvalState& state, const Pos& pos, Value** args,
   state.forceFunction(*args[0], pos);
   state.forceList(*args[1], pos);
 
-  NixList* outlist = new NixList;
+  std::shared_ptr<NixList> outlist = std::make_shared<NixList>();
 
   for (Value* elem : *args[1]->list) {
     auto out = state.allocValue();
diff --git a/third_party/nix/src/libexpr/value.hh b/third_party/nix/src/libexpr/value.hh
index 82360c566813..b5a1a33cba45 100644
--- a/third_party/nix/src/libexpr/value.hh
+++ b/third_party/nix/src/libexpr/value.hh
@@ -96,7 +96,7 @@ struct Value {
     NixString string;
     const char* path;
     std::shared_ptr<Bindings> attrs;
-    NixList* list;
+    std::shared_ptr<NixList> list;
     NixThunk thunk;
     NixApp app;  // TODO(tazjin): "app"?
     NixLambda lambda;