public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v3] resolv/nss_dns/dns-host: Get rid of alloca.
@ 2023-08-14 14:10 Joe Simmons-Talbott
  2023-08-14 14:23 ` Andreas Schwab
  2023-08-14 14:23 ` Siddhesh Poyarekar
  0 siblings, 2 replies; 5+ messages in thread
From: Joe Simmons-Talbott @ 2023-08-14 14:10 UTC (permalink / raw)
  To: libc-alpha; +Cc: Joe Simmons-Talbott

Since the alloca is a small constant size use an array instead.
---
Changes to v2:
  * Move tmp back into lower scope

 resolv/nss_dns/dns-host.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c
index 1d60c51f5e..160a017d42 100644
--- a/resolv/nss_dns/dns-host.c
+++ b/resolv/nss_dns/dns-host.c
@@ -395,8 +395,8 @@ _nss_dns_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat,
    */
   if (strchr (name, '.') == NULL)
     {
-      char *tmp = alloca (NS_MAXDNAME);
-      const char *cp = __res_context_hostalias (ctx, name, tmp, NS_MAXDNAME);
+      char tmp[NS_MAXDNAME];
+      const char *cp = __res_context_hostalias (ctx, name, tmp, sizeof (tmp));
       if (cp != NULL)
 	name = cp;
     }
-- 
2.39.2


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-08-14 15:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-14 14:10 [PATCH v3] resolv/nss_dns/dns-host: Get rid of alloca Joe Simmons-Talbott
2023-08-14 14:23 ` Andreas Schwab
2023-08-14 14:28   ` Siddhesh Poyarekar
2023-08-14 15:01     ` Joe Simmons-Talbott
2023-08-14 14:23 ` Siddhesh Poyarekar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).