1//===-- Implementation of strcat ------------------------------------------===//
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/strcat.h"
10#include "src/__support/macros/config.h"
11#include "src/__support/macros/null_check.h"
12#include "src/string/string_utils.h"
13
14#include "src/__support/common.h"
15
16namespace LIBC_NAMESPACE_DECL {
17
18LLVM_LIBC_FUNCTION(char *, strcat,
19 (char *__restrict dest, const char *__restrict src)) {
20 LIBC_CRASH_ON_NULLPTR(dest);
21 LIBC_CRASH_ON_NULLPTR(src);
22 size_t dest_length = internal::string_length(dest);
23 size_t i;
24 for (i = 0; src[i] != '\0'; ++i)
25 dest[dest_length + i] = src[i];
26
27 dest[dest_length + i] = '\0';
28 return dest;
29}
30
31} // namespace LIBC_NAMESPACE_DECL
32

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