Debian Codegraph @

packages/seacas/libraries/suplib_c/copy_string.c

raw
1 /*
2 * Copyright(C) 1999-2020 National Technology & Engineering Solutions
3 * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
4 * NTESS, the U.S. Government retains certain rights in this software.
5 *
6 * See packages/seacas/LICENSE for details
7 */
8 #include <copy_string.h>
9 /* Safer than strncpy -- guarantees null termination */
10 char *copy_string(char *dest, char const *source, size_t elements)
11 {
12 char *d;
13 for (d = dest; d + 1 < dest + elements && *source; d++, source++) {
14 *d = *source;
15 }
16 *d = '\0';
17 return d;
18 }