[clangd] Re-land "support outgoing calls in call hierarchy" (#117673)
[llvm-project.git] / libc / src / string / strlcat.cpp
blobb5c4c634efa916869bf1c5ef4a3c7e0c4e4792e9
1 //===-- Implementation of strlcat -----------------------------------------===//
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-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "src/string/strlcat.h"
10 #include "src/__support/macros/config.h"
11 #include "src/string/string_utils.h"
13 #include "src/__support/common.h"
15 namespace LIBC_NAMESPACE_DECL {
17 LLVM_LIBC_FUNCTION(size_t, strlcat,
18 (char *__restrict dst, const char *__restrict src,
19 size_t size)) {
20 char *new_dst = reinterpret_cast<char *>(internal::find_first_character(
21 reinterpret_cast<unsigned char *>(dst), 0, size));
22 if (!new_dst)
23 return size + internal::string_length(src);
24 size_t first_len = new_dst - dst;
25 return first_len + internal::strlcpy(new_dst, src, size - first_len);
28 } // namespace LIBC_NAMESPACE_DECL