[NFC][Py Reformat] Added more commits to .git-blame-ignore-revs
[llvm-project.git] / libc / src / string / strlcat.cpp
bloba718de7698838efba36d663b7f19294447b0f179
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/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,
18 size_t size)) {
19 char *new_dst = reinterpret_cast<char *>(internal::find_first_character(
20 reinterpret_cast<unsigned char *>(dst), 0, size));
21 if (!new_dst)
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