about summary refs log tree commit diff
path: root/third_party/nix/src/libexpr/eval.cc
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-22T15·57+0100
committerVincent Ambo <tazjin@google.com>2020-05-22T15·57+0100
commit618f9a6f07b32013c0ad23f83da01e8e6f981d33 (patch)
tree09a04badace14bd9d6f89d0b209c8a23ec851ba3 /third_party/nix/src/libexpr/eval.cc
parentb3c9166b23aebbbfcbe65ea59e7ea18d876d45db (diff)
refactor(3p/nix/libexpr): Use gc_cpp to allocate Value instances r/806
Diffstat (limited to 'third_party/nix/src/libexpr/eval.cc')
-rw-r--r--third_party/nix/src/libexpr/eval.cc24
1 files changed, 4 insertions, 20 deletions
diff --git a/third_party/nix/src/libexpr/eval.cc b/third_party/nix/src/libexpr/eval.cc
index c6804ee114..0abf94c874 100644
--- a/third_party/nix/src/libexpr/eval.cc
+++ b/third_party/nix/src/libexpr/eval.cc
@@ -5,7 +5,10 @@
 #include <cstring>
 #include <fstream>
 #include <iostream>
+#include <new>
 
+#include <gc/gc.h>
+#include <gc/gc_cpp.h>
 #include <glog/logging.h>
 #include <sys/resource.h>
 #include <sys/time.h>
@@ -21,22 +24,11 @@
 #include "store-api.hh"
 #include "util.hh"
 
-#if HAVE_BOEHMGC
-
-#include <gc/gc.h>
-#include <gc/gc_cpp.h>
-
-#endif
-
 namespace nix {
 
 static char* dupString(const char* s) {
   char* t;
-#if HAVE_BOEHMGC
   t = GC_STRDUP(s);
-#else
-  t = strdup(s);
-#endif
   if (t == nullptr) {
     throw std::bad_alloc();
   }
@@ -617,21 +609,13 @@ inline Value* EvalState::lookupVar(Env* env, const ExprVar& var, bool noEval) {
                              var.pos);
     }
     for (size_t l = env->prevWith; l != 0u; --l, env = env->up) {
-      ;
     }
   }
 }
 
-std::atomic<uint64_t> nrValuesFreed{0};
-
-void finalizeValue(void* obj, void* data) { nrValuesFreed++; }
-
 Value* EvalState::allocValue() {
   nrValues++;
-  auto v = (Value*)allocBytes(sizeof(Value));
-  // GC_register_finalizer_no_order(v, finalizeValue, nullptr, nullptr,
-  // nullptr);
-  return v;
+  return new (GC) Value;
 }
 
 Env& EvalState::allocEnv(size_t size) {