Adds strdup implementation. Memcpy is more efficient since we don't need to check if the character is the null terminator with each iteration.
Details
Details
- Reviewers
- None
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
libc/src/string/strdup.cpp | ||
---|---|---|
18 | 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 |
libc/src/string/strdup.cpp | ||
---|---|---|
18 | Ok thanks. I'll close this for now then. |
Comment Actions
Thanks, @tschuett!
@cgyurgyik, That patch has an example of course. In case you decide to add redirectors for free and malloc, feel free to ask questions.
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