From 4835d35acfabe9fed464602fb919279036a49236 Mon Sep 17 00:00:00 2001 From: Sughosh Ganu Date: Wed, 6 May 2020 22:12:41 +0300 Subject: charset: Add support for calculating bytes occupied by a u16 string The current code uses 'u16_strlen(x) + 1) * sizeof(u16)' in various places to calculate the number of bytes occupied by a u16 string. Let's introduce a wrapper around this. This wrapper is used on following patches Signed-off-by: Sughosh Ganu Reviewed-by: Heinrich Schuchardt --- include/charset.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include') diff --git a/include/charset.h b/include/charset.h index fde6bddbc2f..c118cbeb9ab 100644 --- a/include/charset.h +++ b/include/charset.h @@ -195,6 +195,18 @@ int u16_strncmp(const u16 *s1, const u16 *s2, size_t n); */ size_t u16_strlen(const void *in); +/** + * u16_strsize() - count size of u16 string in bytes including the null + * character + * + * Counts the number of bytes occupied by a u16 string + * + * @in: null terminated u16 string + * Return: bytes in a u16 string + * + */ +size_t u16_strsize(const void *in); + /** * u16_strlen - count non-zero words * -- cgit v1.3.1