28 lines · cpp
1//===-- Implementation of wcsdup -----------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#include "src/wchar/wcsdup.h"10#include "hdr/types/wchar_t.h"11#include "src/__support/common.h"12#include "src/__support/libc_errno.h"13#include "src/__support/macros/config.h"14#include "src/string/allocating_string_utils.h"15 16namespace LIBC_NAMESPACE_DECL {17 18LLVM_LIBC_FUNCTION(wchar_t *, wcsdup, (const wchar_t *wcs)) {19 auto dup = internal::strdup(wcs);20 if (dup)21 return *dup;22 if (wcs != nullptr)23 libc_errno = ENOMEM;24 return nullptr;25}26 27} // namespace LIBC_NAMESPACE_DECL28