brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.0 KiB · b5c4c63 Raw
29 lines · cpp
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-exception6//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_DECL29