about summary refs log tree commit diff
path: root/third_party/nix/src
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-22T15·35+0100
committerVincent Ambo <tazjin@google.com>2020-05-22T15·35+0100
commite24466c7951a96b35bea947e6e6854f277eda9d7 (patch)
tree866713350d843739b0a4cba9575b5d41cdc3b612 /third_party/nix/src
parent68e6e92a20b8ee01de3b89e72fc68517fea6f70c (diff)
fix(3p/nix/libexpr): Make new Bindings class visible to GC r/804
Diffstat (limited to 'third_party/nix/src')
-rw-r--r--third_party/nix/src/libexpr/attr-set.cc14
-rw-r--r--third_party/nix/src/libexpr/meson.build1
2 files changed, 9 insertions, 6 deletions
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 <new>
+
 #include <absl/container/btree_map.h>
+#include <gc/gc_cpp.h>
 
 #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 = []