]> Savannah Git Hosting - gnulib.git/commitdiff
mbtowc: Optimize clearing an mbstate_t.
authorBruno Haible <bruno@clisp.org>
Sun, 16 Jul 2023 05:30:20 +0000 (07:30 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 16 Jul 2023 08:29:18 +0000 (10:29 +0200)
* lib/mbtowc-impl.h (mbtowc): Use mbszero.
* modules/mbtowc (Depends-on): Add mbszero.

ChangeLog
lib/mbtowc-impl.h
modules/mbtowc

index 151d9b45376768a9c688429c45b6d69f06b60169..e32eaf8ad4b881f34eff85ee6aa7b2bf245fafc1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-07-16  Bruno Haible  <bruno@clisp.org>
+
+       mbtowc: Optimize clearing an mbstate_t.
+       * lib/mbtowc-impl.h (mbtowc): Use mbszero.
+       * modules/mbtowc (Depends-on): Add mbszero.
+
 2023-07-16  Bruno Haible  <bruno@clisp.org>
 
        mbszero: New module.
index 39b977bebce2e8060d89d51170e406ae3f557287..01fef1823de887b37dcf4d4f699931557b9a1860 100644 (file)
@@ -30,7 +30,7 @@ mbtowc (wchar_t *pwc, const char *s, size_t n)
       wchar_t wc;
       size_t result;
 
-      memset (&state, 0, sizeof (mbstate_t));
+      mbszero (&state);
       result = mbrtowc (&wc, s, n, &state);
       if (result == (size_t)-1 || result == (size_t)-2)
         {
index fcfb1cc431bf456b039efc5d1a836e00a4e2470e..12cc3de62dd673b7e26fae682bef950caca4eee4 100644 (file)
@@ -8,8 +8,9 @@ m4/mbtowc.m4
 
 Depends-on:
 stdlib
-mbrtowc         [test $HAVE_MBTOWC = 0 || test $REPLACE_MBTOWC = 1]
 wchar           [test $HAVE_MBTOWC = 0 || test $REPLACE_MBTOWC = 1]
+mbszero         [test $HAVE_MBTOWC = 0 || test $REPLACE_MBTOWC = 1]
+mbrtowc         [test $HAVE_MBTOWC = 0 || test $REPLACE_MBTOWC = 1]
 
 configure.ac:
 gl_FUNC_MBTOWC