From 928b43eab613970ebe6448b294bba866d43d12bd Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Mon, 21 May 2018 11:09:17 +0200 Subject: Add a fz_strnlen function (strnlen is not standard C). --- source/fitz/string.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source/fitz/string.c') diff --git a/source/fitz/string.c b/source/fitz/string.c index dbcc2c22..a014ce89 100644 --- a/source/fitz/string.c +++ b/source/fitz/string.c @@ -14,6 +14,13 @@ fz_tolower(int c) return c; } +size_t +fz_strnlen(const char *s, size_t n) +{ + const char *p = memchr(s, 0, n); + return p ? p - s : n; +} + int fz_strcasecmp(const char *a, const char *b) { -- cgit v1.2.3