Skip to content

Commit

Permalink
Add function to allocate a Value in traceable memory
Browse files Browse the repository at this point in the history
  • Loading branch information
edolstra committed Apr 16, 2020
1 parent 1290411 commit b3e5eea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/libexpr/eval.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

#if HAVE_BOEHMGC

#define GC_INCLUDE_NEW

#include <gc/gc.h>
#include <gc/gc_cpp.h>

Expand Down Expand Up @@ -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();
Expand Down
5 changes: 5 additions & 0 deletions src/libexpr/value.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}

0 comments on commit b3e5eea

Please sign in to comment.