[libc] Move strdup implementation to a new header
authorJoseph Huber <jhuber6@vols.utk.edu>
Tue, 22 Nov 2022 20:59:13 +0000 (14:59 -0600)
committerJoseph Huber <jhuber6@vols.utk.edu>
Tue, 29 Nov 2022 20:51:52 +0000 (14:51 -0600)
commitd85699eb7d90571b8c39b86774e4ac98058d56f0
tree633ca4417e44244608ae97b0ed12f4e22d3c0680
parent1114d1a9767c8a25c0406eb2350c8963b867586f
[libc] Move strdup implementation to a new header

The `strdup` family of functions rely on `malloc` to be implemented.
Its presence in the `string_utils.h` header meant that compiling many of
the string functions relied on `malloc` being implementated as well.
This patch simply moves the implementation into a new file to avoid
including `stdlib.h` from the other string functions. This was a barrier
for compiling string functions for the GPU where there is no malloc
currently.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D138607
libc/src/string/CMakeLists.txt
libc/src/string/allocating_string_utils.h [new file with mode: 0644]
libc/src/string/strdup.cpp
libc/src/string/string_utils.h
libc/src/unistd/linux/getcwd.cpp