1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 10:41:16 +02:00

Add a few more aliases

This commit is contained in:
Eelco Dolstra 2024-09-19 21:03:59 +02:00
parent 589d8f1f2b
commit 2f4a7a8301
3 changed files with 7 additions and 10 deletions

View file

@ -57,9 +57,7 @@ enum class ProcessLineResult {
struct NixRepl struct NixRepl
: AbstractNixRepl : AbstractNixRepl
, detail::ReplCompleterMixin , detail::ReplCompleterMixin
#if HAVE_BOEHMGC
, gc , gc
#endif
{ {
size_t debugTraceIndex; size_t debugTraceIndex;

View file

@ -13,12 +13,19 @@
#else #else
/* Some dummy aliases for Boehm GC definitions to reduce the number of
#ifdefs. */
template<typename T> template<typename T>
using traceable_allocator = std::allocator<T>; using traceable_allocator = std::allocator<T>;
template<typename T> template<typename T>
using gc_allocator = std::allocator<T>; using gc_allocator = std::allocator<T>;
#define GC_MALLOC_ATOMIC std::malloc
#define GC_STRDUP std::strdup
struct gc { };
#endif #endif
namespace nix { namespace nix {

View file

@ -47,11 +47,7 @@ namespace nix {
static char * allocString(size_t size) static char * allocString(size_t size)
{ {
char * t; char * t;
#if HAVE_BOEHMGC
t = (char *) GC_MALLOC_ATOMIC(size); t = (char *) GC_MALLOC_ATOMIC(size);
#else
t = (char *) malloc(size);
#endif
if (!t) throw std::bad_alloc(); if (!t) throw std::bad_alloc();
return t; return t;
} }
@ -60,11 +56,7 @@ static char * allocString(size_t size)
static char * dupString(const char * s) static char * dupString(const char * s)
{ {
char * t; char * t;
#if HAVE_BOEHMGC
t = GC_STRDUP(s); t = GC_STRDUP(s);
#else
t = strdup(s);
#endif
if (!t) throw std::bad_alloc(); if (!t) throw std::bad_alloc();
return t; return t;
} }