From 618f9a6f07b32013c0ad23f83da01e8e6f981d33 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 22 May 2020 16:57:48 +0100 Subject: refactor(3p/nix/libexpr): Use gc_cpp to allocate Value instances --- third_party/nix/src/libexpr/eval.cc | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) (limited to 'third_party/nix/src') diff --git a/third_party/nix/src/libexpr/eval.cc b/third_party/nix/src/libexpr/eval.cc index c6804ee1143d..0abf94c87445 100644 --- a/third_party/nix/src/libexpr/eval.cc +++ b/third_party/nix/src/libexpr/eval.cc @@ -5,7 +5,10 @@ #include #include #include +#include +#include +#include #include #include #include @@ -21,22 +24,11 @@ #include "store-api.hh" #include "util.hh" -#if HAVE_BOEHMGC - -#include -#include - -#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 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) { -- cgit 1.4.1