scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit a6e12fcc40f07b3e465dba61249f86e1b2b25d38
parent 68ad37c9bee5f12c0804f165a5176e4bbf4b4898
Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date:   Fri, 28 Mar 2025 12:49:17 +0100

libc/wchar: Remove useless state in wc*

We don't use state in conversions from wchar to mb, so
it is useless to have static variables that don't mean
anything.

Diffstat:
Msrc/libc/stdlib/wcstombs.c | 8+++++---
Msrc/libc/stdlib/wctomb.c | 8+++++---
2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/libc/stdlib/wcstombs.c b/src/libc/stdlib/wcstombs.c @@ -3,10 +3,12 @@ #undef wcstombs +/* + * We don't use any state in the wc* functions + * so we don't need a mbstate_t variable + */ size_t wcstombs(char *restrict dest, const wchar_t *restrict src, size_t n) { - static mbstate_t st; - - return wcsrtombs(dest, (void *) &src, n, &st); + return wcsrtombs(dest, (void *) &src, n, NULL); } diff --git a/src/libc/stdlib/wctomb.c b/src/libc/stdlib/wctomb.c @@ -3,10 +3,12 @@ #undef wctomb +/* + * We don't use any state in the wc* functions + * so we don't need a mbstate_t variable + */ int wctomb(char *s, wchar_t wc) { - static mbstate_t st; - - return wcrtomb(s, wc, &st); + return wcrtomb(s, wc, NULL); }