about summary refs log tree commit diff
path: root/third_party/nix/src
diff options
context:
space:
mode:
authorKane York <kanepyork@gmail.com>2020-09-12T15·40-0700
committerkanepyork <rikingcoding@gmail.com>2020-09-15T21·52+0000
commitfedbe693b9c0f5ba57fae82e3191efe8a633aa09 (patch)
tree2f8705f9607eeb07d8084e36efcac8d4281a13b3 /third_party/nix/src
parentd9c7f32a9c8644acef4569509be0de8f1c82ff6c (diff)
refactor(3p/tvix): make Value.primOp a std::shared_ptr r/1794
Change-Id: I04cc42ae62d2ff71b07fde8e3710dcc9b4363a05
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1973
Reviewed-by: glittershark <grfn@gws.fyi>
Tested-by: BuildkiteCI
Diffstat (limited to 'third_party/nix/src')
-rw-r--r--third_party/nix/src/libexpr/eval.cc5
-rw-r--r--third_party/nix/src/libexpr/value.hh2
2 files changed, 3 insertions, 4 deletions
diff --git a/third_party/nix/src/libexpr/eval.cc b/third_party/nix/src/libexpr/eval.cc
index 2a0aba1a4c8b..e15741811738 100644
--- a/third_party/nix/src/libexpr/eval.cc
+++ b/third_party/nix/src/libexpr/eval.cc
@@ -434,13 +434,12 @@ Value* EvalState::addPrimOp(const std::string& name, size_t arity,
     primOp(*this, noPos, nullptr, v);
     return addConstant(name, v);
   }
-  Value* v = allocValue();
   std::string name2 =
       std::string(name, 0, 2) == "__" ? std::string(name, 2) : name;
   Symbol sym = symbols.Create(name2);
-  // Even though PrimOp doesn't need tracing, it needs to be collected.
+  Value* v = allocValue();
   v->type = tPrimOp;
-  v->primOp = new PrimOp(primOp, arity, sym);
+  v->primOp = std::make_shared<PrimOp>(primOp, arity, sym);
   staticBaseEnv.vars[symbols.Create(name)] = baseEnvDispl;
   baseEnv.values[baseEnvDispl++] = v;
   baseEnv.values[0]->attrs->push_back(Attr(sym, v));
diff --git a/third_party/nix/src/libexpr/value.hh b/third_party/nix/src/libexpr/value.hh
index 980d9affbb51..82021c77c41b 100644
--- a/third_party/nix/src/libexpr/value.hh
+++ b/third_party/nix/src/libexpr/value.hh
@@ -100,7 +100,7 @@ struct Value {
     NixThunk thunk;
     NixApp app;  // TODO(tazjin): "app"?
     NixLambda lambda;
-    PrimOp* primOp;
+    std::shared_ptr<PrimOp> primOp;
     NixPrimOpApp primOpApp;
     NixFloat fpoint;
   };