1 //===-- Implementation of strlcat -----------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "src/string/strlcat.h"
10 #include "src/string/string_utils.h"
12 #include "src/__support/common.h"
14 namespace __llvm_libc
{
16 LLVM_LIBC_FUNCTION(size_t, strlcat
,
17 (char *__restrict dst
, const char *__restrict src
,
19 char *new_dst
= reinterpret_cast<char *>(internal::find_first_character(
20 reinterpret_cast<unsigned char *>(dst
), 0, size
));
22 return size
+ internal::string_length(src
);
23 size_t first_len
= new_dst
- dst
;
24 return first_len
+ internal::strlcpy(new_dst
, src
, size
- first_len
);
27 } // namespace __llvm_libc