Add function to allocate a Value in traceable memory

This commit is contained in:
Eelco Dolstra 2020-04-16 16:28:07 +02:00
parent 1290411c2d
commit b3e5eea4a9
2 changed files with 13 additions and 0 deletions

View file

@ -22,6 +22,8 @@
#if HAVE_BOEHMGC #if HAVE_BOEHMGC
#define GC_INCLUDE_NEW
#include <gc/gc.h> #include <gc/gc.h>
#include <gc/gc_cpp.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) static void printValue(std::ostream & str, std::set<const Value *> & active, const Value & v)
{ {
checkInterrupt(); checkInterrupt();

View file

@ -261,4 +261,9 @@ typedef std::map<Symbol, Value *> ValueMap;
#endif #endif
/* A value allocated in traceable memory. */
typedef std::shared_ptr<Value *> RootValue;
RootValue allocRootValue(Value * v);
} }