Fix an off by one in strnlena()

I wrote a test case for strnlena() and strndupa() and of course both
were off by one in the opposite directions...

... but the next patch obviates the need for them, hopefully, so this
will wind up getting dropped.
This commit is contained in:
Peter Jones 2021-02-15 11:41:08 -05:00 committed by Jan Setje-Eilers
parent 066a11164e
commit 07724ab645

View File

@ -3,12 +3,11 @@
#ifndef SHIM_STR_H
#define SHIM_STR_H
static inline
__attribute__((unused))
unsigned long strnlena(const CHAR8 *s, unsigned long n)
static inline __attribute__((unused)) unsigned long
strnlena(const CHAR8 *s, unsigned long n)
{
unsigned long i;
for (i = 0; i <= n; i++)
for (i = 0; i < n; i++)
if (s[i] == '\0')
break;
return i;