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