From 6ad0a2f749b4db6b24e8b86625883b0b43ad7ba1 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 11 Jun 2018 15:58:19 +0200 Subject: Remove duplicate definition of allocBytes() --- src/libexpr/eval-inline.hh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/libexpr/eval-inline.hh') diff --git a/src/libexpr/eval-inline.hh b/src/libexpr/eval-inline.hh index 8cc50e561354..ad172c37c7b9 100644 --- a/src/libexpr/eval-inline.hh +++ b/src/libexpr/eval-inline.hh @@ -78,4 +78,18 @@ inline void EvalState::forceList(Value & v, const Pos & pos) throwTypeError("value is %1% while a list was expected, at %2%", v, pos); } +/* Note: Various places expect the allocated memory to be zeroed. */ +inline void * allocBytes(size_t n) +{ + void * p; +#if HAVE_BOEHMGC + p = GC_malloc(n); +#else + p = calloc(n, 1); +#endif + if (!p) throw std::bad_alloc(); + return p; +} + + } -- cgit 1.4.1