aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-04-16 16:28:07 +0200
committerEelco Dolstra <edolstra@gmail.com>2020-04-16 17:30:05 +0200
commitb3e5eea4a91400fb2a12aba4b07a94d03ba54605 (patch)
tree5b0722d06ae8c45b3619fd32348eeaf34e12aa0b /src
parent1290411c2d0c62dd1761485f55292dc944eae55d (diff)
Add function to allocate a Value in traceable memory
Diffstat (limited to 'src')
-rw-r--r--src/libexpr/eval.cc8
-rw-r--r--src/libexpr/value.hh5
2 files changed, 13 insertions, 0 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index f963a42ca..2f5b1db47 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -22,6 +22,8 @@
#if HAVE_BOEHMGC
+#define GC_INCLUDE_NEW
+
#include <gc/gc.h>
#include <gc/gc_cpp.h>
@@ -56,6 +58,12 @@ static char * dupStringWithLen(const char * s, size_t size)
}
+RootValue allocRootValue(Value * v)
+{
+ return std::allocate_shared<Value *>(traceable_allocator<Value *>(), v);
+}
+
+
static void printValue(std::ostream & str, std::set<const Value *> & active, const Value & v)
{
checkInterrupt();
diff --git a/src/libexpr/value.hh b/src/libexpr/value.hh
index 689373873..9cf2bf06a 100644
--- a/src/libexpr/value.hh
+++ b/src/libexpr/value.hh
@@ -261,4 +261,9 @@ typedef std::map<Symbol, Value *> ValueMap;
#endif
+/* A value allocated in traceable memory. */
+typedef std::shared_ptr<Value *> RootValue;
+
+RootValue allocRootValue(Value * v);
+
}