From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2206) id B0FE43858409; Tue, 1 Mar 2022 02:41:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B0FE43858409 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Siddhesh Poyarekar To: glibc-cvs@sourceware.org Subject: [glibc/siddhesh/gai-cleanup2] gaih_inet: Put name copy under gaih_lookup cache X-Act-Checkin: glibc X-Git-Author: Siddhesh Poyarekar X-Git-Refname: refs/heads/siddhesh/gai-cleanup2 X-Git-Oldrev: e9942569d128646a2ab19128bf3b01801e22e207 X-Git-Newrev: f66eb74240baa93a5a06eed517322d9a4a131ed4 Message-Id: <20220301024137.B0FE43858409@sourceware.org> Date: Tue, 1 Mar 2022 02:41:37 +0000 (GMT) X-BeenThere: glibc-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Mar 2022 02:41:37 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=f66eb74240baa93a5a06eed517322d9a4a131ed4 commit f66eb74240baa93a5a06eed517322d9a4a131ed4 Author: Siddhesh Poyarekar Date: Mon Feb 28 23:34:50 2022 +0530 gaih_inet: Put name copy under gaih_lookup cache Signed-off-by: Siddhesh Poyarekar Diff: --- sysdeps/posix/getaddrinfo.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c index 036a9539b0..f790921487 100644 --- a/sysdeps/posix/getaddrinfo.c +++ b/sysdeps/posix/getaddrinfo.c @@ -1218,7 +1218,6 @@ gaih_inet (const char *name, const struct gaih_service *service, if ((rc = get_servtuples (service, req, st, tmpbuf)) != 0) return rc; - bool malloc_name = false; int result = 0; struct gaih_lookup_result res = {0}; struct scratch_buffer resbuf; @@ -1226,6 +1225,8 @@ gaih_inet (const char *name, const struct gaih_service *service, if (name != NULL) { + gaih_lookup_result_init (&res, &resbuf); + if (req->ai_flags & AI_IDN) { char *out; @@ -1233,11 +1234,9 @@ gaih_inet (const char *name, const struct gaih_service *service, if (result != 0) return -result; name = out; - malloc_name = true; + gaih_lookup_result_push_alloc (&res, out); } - gaih_lookup_result_init (&res, &resbuf); - if ((result = get_numeric_res (name, req, &res)) != 0) goto free_and_return; else if (res.at != NULL) @@ -1292,8 +1291,6 @@ process_list: result = generate_addrinfo (canon, req, &res, st, pai, naddrs); free_and_return: - if (malloc_name) - free ((char *) name); if (result != 0) free (canon); gaih_lookup_result_free (&res);