Skip to content

Commit

Permalink
Add a few more aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
edolstra committed Sep 19, 2024
1 parent 589d8f1 commit 2f4a7a8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
2 changes: 0 additions & 2 deletions src/libcmd/repl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ enum class ProcessLineResult {
struct NixRepl
: AbstractNixRepl
, detail::ReplCompleterMixin
#if HAVE_BOEHMGC
, gc
#endif
{
size_t debugTraceIndex;

Expand Down
7 changes: 7 additions & 0 deletions src/libexpr/eval-gc.hh
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,19 @@

#else

/* Some dummy aliases for Boehm GC definitions to reduce the number of
#ifdefs. */

template<typename T>
using traceable_allocator = std::allocator<T>;

template<typename T>
using gc_allocator = std::allocator<T>;

#define GC_MALLOC_ATOMIC std::malloc
#define GC_STRDUP std::strdup
struct gc { };

#endif

namespace nix {
Expand Down
8 changes: 0 additions & 8 deletions src/libexpr/eval.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ namespace nix {
static char * allocString(size_t size)
{
char * t;
#if HAVE_BOEHMGC
t = (char *) GC_MALLOC_ATOMIC(size);
#else
t = (char *) malloc(size);
#endif
if (!t) throw std::bad_alloc();
return t;
}
Expand All @@ -60,11 +56,7 @@ static char * allocString(size_t size)
static char * dupString(const char * s)
{
char * t;
#if HAVE_BOEHMGC
t = GC_STRDUP(s);
#else
t = strdup(s);
#endif
if (!t) throw std::bad_alloc();
return t;
}
Expand Down

0 comments on commit 2f4a7a8

Please sign in to comment.