[libc-commits] [PATCH] D82376: [libc] Add strdup implementation.
Alex Brachet via Phabricator via libc-commits
libc-commits at lists.llvm.org
Tue Jun 23 08:31:34 PDT 2020
abrachet added inline comments.
================
Comment at: libc/src/string/strdup.cpp:18
+ const size_t length = __llvm_libc::strlen(s) + 1;
+ char *duplicate = new char[length];
+ if (!duplicate)
----------------
We can't use `new` unfortunately. Even if `operator new` was a completely free standing allocator which didn't depend on libc functions we may not provide, `operator new[]` is not guaranteed to be free-able by `free`. This function has to wait for `malloc`
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D82376/new/
https://reviews.llvm.org/D82376
More information about the libc-commits
mailing list