17dff02feSmrg/* 27dff02feSmrg * Copyright (c) 2009 Apple Inc. 37dff02feSmrg * 47dff02feSmrg * Permission is hereby granted, free of charge, to any person obtaining a 57dff02feSmrg * copy of this software and associated documentation files (the "Software"), 67dff02feSmrg * to deal in the Software without restriction, including without limitation 77dff02feSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 87dff02feSmrg * and/or sell copies of the Software, and to permit persons to whom the 97dff02feSmrg * Software is furnished to do so, subject to the following conditions: 107dff02feSmrg * 117dff02feSmrg * The above copyright notice and this permission notice shall be included in 127dff02feSmrg * all copies or substantial portions of the Software. 137dff02feSmrg * 147dff02feSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 157dff02feSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 167dff02feSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 177dff02feSmrg * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 187dff02feSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 197dff02feSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 207dff02feSmrg * DEALINGS IN THE SOFTWARE. 217dff02feSmrg */ 227dff02feSmrg 237dff02feSmrg /* 247dff02feSmrg * Author: Jeremy Huddleston, Apple Inc. 257dff02feSmrg */ 267dff02feSmrg 277dff02feSmrg#ifdef HAVE_CONFIG_H 287dff02feSmrg#include "config.h" 297dff02feSmrg#endif 307dff02feSmrg 317dff02feSmrg#include <strnlen.h> 327dff02feSmrg#include <string.h> 337dff02feSmrg 347dff02feSmrgsize_t strnlen(const char *s, size_t maxlen) { 357dff02feSmrg const char *p = memchr(s, 0, maxlen); 367dff02feSmrg return (size_t)(p ? (p - s) : maxlen); 377dff02feSmrg} 38