brintos

brintos / llvm-project-archived public Read only

0
0
Text · 986 B · 7dce6d1 Raw
32 lines · cpp
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-exception6//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_DECL32