1 /*
2 ** Copyright 2004, Travis Geiselbrecht. All rights reserved.
3 ** Distributed under the terms of the NewOS License.
4 */
5 /*
6  * Copyright (c) 2008 Travis Geiselbrecht
7  *
8  * Use of this source code is governed by a MIT-style
9  * license that can be found in the LICENSE file or at
10  * https://opensource.org/licenses/MIT
11  */
12 #include <string.h>
13 #include <sys/types.h>
14 
15 size_t
strxfrm(char * dest,const char * src,size_t n)16 strxfrm(char *dest, const char *src, size_t n) {
17     size_t len = strlen(src);
18 
19     if (n) {
20         size_t copy_len = len < n ? len : n - 1;
21         memcpy(dest, src, copy_len);
22         dest[copy_len] = 0;
23     }
24     return len;
25 }
26 
27