1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2024-10-18 00:16:11 -04:00

eval: remove superfluous strdup

This commit is contained in:
Philipp Otterbein 2024-09-30 22:15:04 +02:00
parent 14f029dbe8
commit 5cf6b2cb75
2 changed files with 4 additions and 13 deletions

View file

@ -23,7 +23,6 @@ template<typename T>
using gc_allocator = std::allocator<T>;
# define GC_MALLOC_ATOMIC std::malloc
# define GC_STRDUP strdup
struct gc
{};

View file

@ -53,15 +53,6 @@ static char * allocString(size_t size)
}
static char * dupString(const char * s)
{
char * t;
t = GC_STRDUP(s);
if (!t) throw std::bad_alloc();
return t;
}
// When there's no need to write to the string, we can optimize away empty
// string allocations.
// This function handles makeImmutableString(std::string_view()) by returning
@ -832,9 +823,10 @@ static const char * * encodeContext(const NixStringContext & context)
size_t n = 0;
auto ctx = (const char * *)
allocBytes((context.size() + 1) * sizeof(char *));
for (auto & i : context)
ctx[n++] = dupString(i.to_string().c_str());
ctx[n] = 0;
for (auto & i : context) {
ctx[n++] = makeImmutableString({i.to_string()});
}
ctx[n] = nullptr;
return ctx;
} else
return nullptr;