bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

striconveh, *vasnprintf, vasnwprintf: Make more virtual-memory friendly


From: Bruno Haible
Subject: striconveh, *vasnprintf, vasnwprintf: Make more virtual-memory friendly
Date: Fri, 22 Sep 2023 09:37:00 +0200

It is more virtual-memory efficient to have read-only data in the .text
segment than in the .data segment. See Ulrich Drepper's famous paper
<https://akkadia.org/drepper/dsohowto.pdf>, section 2.4.2.


2023-09-22  Bruno Haible  <bruno@clisp.org>

        striconveh, *vasnprintf, vasnwprintf: Make more virtual-memory friendly.
        * lib/striconveh.c (mem_cd_iconveh_internal): Mark hex as 'const'.
        * lib/vasnprintf.c (wctomb_fallback): Likewise.

diff --git a/lib/striconveh.c b/lib/striconveh.c
index 0209dc6cf2..be60407373 100644
--- a/lib/striconveh.c
+++ b/lib/striconveh.c
@@ -810,7 +810,7 @@ mem_cd_iconveh_internal (const char *src, size_t srclen,
 
                         if (handler == iconveh_escape_sequence)
                           {
-                            static char hex[16] = "0123456789ABCDEF";
+                            static char const hex[16] = "0123456789ABCDEF";
                             scratchlen = 0;
                             scratchbuf[scratchlen++] = '\\';
                             if (uc < 0x10000)
diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c
index 2d9aa977ec..815c7c5098 100644
--- a/lib/vasnprintf.c
+++ b/lib/vasnprintf.c
@@ -294,7 +294,7 @@ local_wcsnlen (const wchar_t *s, size_t maxlen)
 static size_t
 wctomb_fallback (char *s, wchar_t wc)
 {
-  static char hex[16] = "0123456789ABCDEF";
+  static char const hex[16] = "0123456789ABCDEF";
 
   s[0] = '\\';
   if (sizeof (wchar_t) > 2 && wc > 0xffff)






reply via email to

[Prev in Thread] Current Thread [Next in Thread]