PBL: Add strnlen, needed for printf support
vsprintf needs strnlen, so in oder to add console support to the PBL we need a strnlen implementation. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
631be8e6cb
commit
c20983fad5
14
pbl/string.c
14
pbl/string.c
|
@ -119,3 +119,17 @@ void *memset(void *s, int c, size_t count)
|
||||||
*xs++ = c;
|
*xs++ = c;
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* strnlen - Find the length of a length-limited string
|
||||||
|
* @s: The string to be sized
|
||||||
|
* @count: The maximum number of bytes to search
|
||||||
|
*/
|
||||||
|
size_t strnlen(const char * s, size_t count)
|
||||||
|
{
|
||||||
|
const char *sc;
|
||||||
|
|
||||||
|
for (sc = s; count-- && *sc != '\0'; ++sc)
|
||||||
|
/* nothing */;
|
||||||
|
return sc - s;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue