Path: blob/main/system/lib/llvm-libc/src/string/strdup.cpp
6175 views
//===-- Implementation of strdup ------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "src/string/strdup.h"9#include "hdr/stdlib_macros.h"10#include "src/__support/libc_errno.h"11#include "src/__support/macros/config.h"12#include "src/string/allocating_string_utils.h"13#include "src/string/memory_utils/inline_memcpy.h"1415#include "src/__support/common.h"1617namespace LIBC_NAMESPACE_DECL {1819LLVM_LIBC_FUNCTION(char *, strdup, (const char *src)) {20auto dup = internal::strdup(src);21if (dup)22return *dup;23if (src != nullptr)24libc_errno = ENOMEM;25return nullptr;26}2728} // namespace LIBC_NAMESPACE_DECL293031