mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 05:56:15 +02:00
Merge pull request #7350 from edolstra/remove-strndup
Don't use GC_STRNDUP
This commit is contained in:
commit
534332c8a0
1 changed files with 3 additions and 7 deletions
|
@ -69,15 +69,11 @@ static char * dupString(const char * s)
|
|||
// empty string.
|
||||
static const char * makeImmutableStringWithLen(const char * s, size_t size)
|
||||
{
|
||||
char * t;
|
||||
if (size == 0)
|
||||
return "";
|
||||
#if HAVE_BOEHMGC
|
||||
t = GC_STRNDUP(s, size);
|
||||
#else
|
||||
t = strndup(s, size);
|
||||
#endif
|
||||
if (!t) throw std::bad_alloc();
|
||||
auto t = allocString(size + 1);
|
||||
memcpy(t, s, size);
|
||||
t[size] = 0;
|
||||
return t;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue