1 /*-------------------------------------------------------------------------
4 * Fallback implementation of strnlen().
7 * Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
13 *-------------------------------------------------------------------------
19 * Implementation of posix' strnlen for systems where it's not available.
21 * Returns the number of characters before a null-byte in the string pointed
22 * to by str, unless there's no null-byte before maxlen. In the latter case
26 strnlen(const char *str
, size_t maxlen
)
30 while (maxlen
-- > 0 && *p
)