Module Name: src Committed By: christos Date: Tue Dec 31 20:56:29 UTC 2013
Modified Files: src/external/bsd/ntp/dist/libntp: ntp_intres.c Log Message: pointless to call alloca for a 1K path string... Just allocate it on the stack! To generate a diff of this commit: cvs rdiff -u -r1.1.1.1 -r1.2 src/external/bsd/ntp/dist/libntp/ntp_intres.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/external/bsd/ntp/dist/libntp/ntp_intres.c diff -u src/external/bsd/ntp/dist/libntp/ntp_intres.c:1.1.1.1 src/external/bsd/ntp/dist/libntp/ntp_intres.c:1.2 --- src/external/bsd/ntp/dist/libntp/ntp_intres.c:1.1.1.1 Fri Dec 27 18:30:47 2013 +++ src/external/bsd/ntp/dist/libntp/ntp_intres.c Tue Dec 31 15:56:29 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: ntp_intres.c,v 1.1.1.1 2013/12/27 23:30:47 christos Exp $ */ +/* $NetBSD: ntp_intres.c,v 1.2 2013/12/31 20:56:29 christos Exp $ */ /* * ntp_intres.c - Implements a generic blocking worker child or thread, @@ -691,6 +691,7 @@ blocking_getnameinfo( char * cp; int rc; time_t time_now; + char host[1024]; gni_req = (void *)((char *)req + sizeof(*req)); @@ -701,19 +702,7 @@ blocking_getnameinfo( * large allocations. We only need room for the host * and service names. */ - NTP_REQUIRE(octets < 1024); - -#ifndef HAVE_ALLOCA - host = emalloc(octets); -#else - host = alloca(octets); - if (NULL == host) { - msyslog(LOG_ERR, - "blocking_getnameinfo unable to allocate %lu octets on stack", - (u_long)octets); - exit(1); - } -#endif + NTP_REQUIRE(octets < sizeof(host)); service = host + gni_req->hostoctets; worker_ctx = get_worker_context(c, gni_req->dns_idx); @@ -795,9 +784,6 @@ blocking_getnameinfo( rc = queue_blocking_response(c, resp, resp_octets, req); if (rc) msyslog(LOG_ERR, "blocking_getnameinfo unable to queue response"); -#ifndef HAVE_ALLOCA - free(host); -#endif return rc; }