13f5abb3jkim/*-
2cc22a86pfg * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3cc22a86pfg *
43f5abb3jkim * Copyright (c) 2009 David Schultz <das@FreeBSD.org>
53f5abb3jkim * All rights reserved.
63f5abb3jkim *
73f5abb3jkim * Redistribution and use in source and binary forms, with or without
83f5abb3jkim * modification, are permitted provided that the following conditions
93f5abb3jkim * are met:
103f5abb3jkim * 1. Redistributions of source code must retain the above copyright
113f5abb3jkim *    notice, this list of conditions and the following disclaimer.
123f5abb3jkim * 2. Redistributions in binary form must reproduce the above copyright
133f5abb3jkim *    notice, this list of conditions and the following disclaimer in the
143f5abb3jkim *    documentation and/or other materials provided with the distribution.
153f5abb3jkim *
163f5abb3jkim * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
173f5abb3jkim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
183f5abb3jkim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
193f5abb3jkim * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
203f5abb3jkim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
213f5abb3jkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
223f5abb3jkim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
233f5abb3jkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
243f5abb3jkim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
253f5abb3jkim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
263f5abb3jkim * SUCH DAMAGE.
273f5abb3jkim */
283f5abb3jkim
293f5abb3jkim#include <sys/cdefs.h>
303f5abb3jkim__FBSDID("$FreeBSD$");
313f5abb3jkim
323f5abb3jkim#include <sys/libkern.h>
333f5abb3jkim
343f5abb3jkimsize_t
353f5abb3jkimstrnlen(const char *s, size_t maxlen)
363f5abb3jkim{
373f5abb3jkim	size_t len;
383f5abb3jkim
393f5abb3jkim	for (len = 0; len < maxlen; len++, s++) {
403f5abb3jkim		if (!*s)
413f5abb3jkim			break;
423f5abb3jkim	}
433f5abb3jkim	return (len);
443f5abb3jkim}
45