From e568a5a3ba4f2de4a123c0734cc4226597a91713 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 16 Jul 2023 07:30:41 +0200 Subject: [PATCH] c32stombs: Optimize clearing an mbstate_t. * lib/c32stombs.c (c32stombs): Use mbszero. * lib/uchar.in.h (c32stombs): Likewise. * modules/c32stombs (Depends-on): Add mbszero. --- ChangeLog | 7 +++++++ lib/c32stombs.c | 2 +- lib/uchar.in.h | 2 +- modules/c32stombs | 1 + 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index b5d26043aa..d89119176f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2023-07-16 Bruno Haible + + c32stombs: Optimize clearing an mbstate_t. + * lib/c32stombs.c (c32stombs): Use mbszero. + * lib/uchar.in.h (c32stombs): Likewise. + * modules/c32stombs (Depends-on): Add mbszero. + 2023-07-16 Bruno Haible mbstoc32s: Optimize clearing an mbstate_t. diff --git a/lib/c32stombs.c b/lib/c32stombs.c index 86e84b2fe7..17a4e1ab61 100644 --- a/lib/c32stombs.c +++ b/lib/c32stombs.c @@ -32,6 +32,6 @@ c32stombs (char *dest, const char32_t *src, size_t len) { mbstate_t state; - memset (&state, '\0', sizeof (mbstate_t)); + mbszero (&state); return c32srtombs (dest, &src, len, &state); } diff --git a/lib/uchar.in.h b/lib/uchar.in.h index b3fa531d08..15c4818aed 100644 --- a/lib/uchar.in.h +++ b/lib/uchar.in.h @@ -482,7 +482,7 @@ c32stombs (char *dest, const char32_t *src, size_t len) { mbstate_t state; - memset (&state, '\0', sizeof (mbstate_t)); + mbszero (&state); return c32srtombs (dest, &src, len, &state); } _GL_END_C_LINKAGE diff --git a/modules/c32stombs b/modules/c32stombs index 1067c433af..103c8758c0 100644 --- a/modules/c32stombs +++ b/modules/c32stombs @@ -7,6 +7,7 @@ lib/c32stombs.c Depends-on: uchar wchar +mbszero c32srtombs configure.ac: -- 2.39.5