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//===----------------------------------------------------------------------===//
8
9#include "src/string/strlcat.h"
10#include "src/__support/macros/config.h"
11#include "src/string/string_utils.h"
12
13#include "src/__support/common.h"
14
15namespace LIBC_NAMESPACE_DECL {
16
17LLVM_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);
26}
27
28} // namespace LIBC_NAMESPACE_DECL
29

source code of libc/src/string/strlcat.cpp