about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-22T22·43+0100
committerVincent Ambo <tazjin@google.com>2020-05-22T22·43+0100
commit8c28be1b69a66f16fd1c711931b5a6f6948a8a2a (patch)
treec8a21dfff5948d4b21a56fc2ebc444673728d87d
parent5f728cb428ee0e4d9c6afb9df7deb20ce8b8779b (diff)
fix(3p/nix/libexpr): Use gc_allocator<T> as the btree_map allocator r/817
This will make all Attr values visible to the GC.
-rw-r--r--third_party/nix/src/libexpr/attr-set.hh9
1 files changed, 8 insertions, 1 deletions
diff --git a/third_party/nix/src/libexpr/attr-set.hh b/third_party/nix/src/libexpr/attr-set.hh
index caddc6bebd61..5837b5cbdc9c 100644
--- a/third_party/nix/src/libexpr/attr-set.hh
+++ b/third_party/nix/src/libexpr/attr-set.hh
@@ -2,10 +2,11 @@
 #pragma once
 
 #include <absl/container/btree_map.h>
+#include <gc/gc_allocator.h>
 
 #include "nixexpr.hh"
 #include "symbol-table.hh"
-#include "types.hh"  // TODO(tazjin): audit this include
+#include "types.hh"
 
 namespace nix {  // TODO(tazjin): ::expr
 
@@ -29,6 +30,12 @@ inline bool operator==(const Attr& lhs, const Attr& rhs) {
   return lhs.name == rhs.name;
 }
 
+// Convenience alias for the backing map, with the garbage-collecting
+// allocator explicitly specified.
+using AttributeMap =
+    absl::btree_map<Symbol, Attr, std::less<Symbol>,
+                    gc_allocator<std::pair<const Symbol, Attr>>>;
+
 class Bindings {
  public:
   typedef absl::btree_map<Symbol, Attr>::iterator iterator;