From e24466c7951a96b35bea947e6e6854f277eda9d7 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 22 May 2020 16:35:21 +0100 Subject: fix(3p/nix/libexpr): Make new Bindings class visible to GC --- third_party/nix/src/libexpr/attr-set.cc | 14 ++++++++------ third_party/nix/src/libexpr/meson.build | 1 + 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'third_party/nix') diff --git a/third_party/nix/src/libexpr/attr-set.cc b/third_party/nix/src/libexpr/attr-set.cc index eb9db3f46d69..71777c95dc7b 100644 --- a/third_party/nix/src/libexpr/attr-set.cc +++ b/third_party/nix/src/libexpr/attr-set.cc @@ -1,6 +1,9 @@ #include "attr-set.hh" +#include + #include +#include #include "eval-inline.hh" @@ -46,12 +49,11 @@ void Bindings::merge(Bindings* other) { attributes_.swap(other->attributes_); } -// /* Allocate a new array of attributes for an attribute set with a specific -// capacity. The space is implicitly reserved after the Bindings structure. -// */ -Bindings* EvalState::allocBindings(size_t _capacity) { return new Bindings; } +// Allocate a new attribute set, making it visible to the garbage collector. +Bindings* EvalState::allocBindings(size_t _capacity) { + return new (GC) Bindings; +} -// TODO(tazjin): What's Value? What's going on here? void EvalState::mkAttrs(Value& v, size_t capacity) { if (capacity == 0) { v = vEmptySet; @@ -59,7 +61,7 @@ void EvalState::mkAttrs(Value& v, size_t capacity) { } clearValue(v); v.type = tAttrs; - v.attrs = new Bindings; + v.attrs = new (GC) Bindings; nrAttrsets++; nrAttrsInAttrsets += capacity; } diff --git a/third_party/nix/src/libexpr/meson.build b/third_party/nix/src/libexpr/meson.build index 1bb311e999d1..ce50838b9744 100644 --- a/third_party/nix/src/libexpr/meson.build +++ b/third_party/nix/src/libexpr/meson.build @@ -53,6 +53,7 @@ libexpr_link_list = [ libexpr_link_args = [ '-lpthread', + '-lgccpp', ] libexpr_cxx_args = [] -- cgit 1.4.1