about summary refs log tree commit diff
path: root/third_party/nix/src/libexpr/primops.cc
diff options
context:
space:
mode:
authorKane York <kanepyork@gmail.com>2020-09-12T15·09-0700
committerkanepyork <rikingcoding@gmail.com>2020-09-15T21·42+0000
commit2c19bd666280c33eb63d3f3b9063b07b62023c9d (patch)
treed76281f3c93e917dd9fe0c7fae3f219209d2b7c5 /third_party/nix/src/libexpr/primops.cc
parent381ce8a66658ac9d02c44e96c860cd05bcb6a5f8 (diff)
refactor(3p/tvix): convert NixList usage to shared_ptr r/1792
Starting to reclaim memory. Fairly simple mechanical replacement.

Change-Id: I6b4c5c5596729470d1a049eba61e69e8097decf4
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1971
Tested-by: BuildkiteCI
Reviewed-by: glittershark <grfn@gws.fyi>
Diffstat (limited to 'third_party/nix/src/libexpr/primops.cc')
-rw-r--r--third_party/nix/src/libexpr/primops.cc8
1 files changed, 4 insertions, 4 deletions
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();