Date: Sat, 12 Apr 2008 15:58:27 GMT From: "Christian S.J. Peron" <csjp@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 139902 for review Message-ID: <200804121558.m3CFwRKq079552@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=139902 Change 139902 by csjp@ibm01 on 2008/04/12 15:58:26 Allocate a timeval on the stack and conditionally initialize the timeout if we need it. If so, initialize the timeval pointer to the stack to avoid potentially expensive malloc calls. Affected files ... .. //depot/projects/trustedbsd/netauditd/writer.c#5 edit Differences ... ==== //depot/projects/trustedbsd/netauditd/writer.c#5 (text+ko) ==== @@ -63,17 +63,18 @@ { struct au_cmpnt *ac; fd_set lwfds; - struct timeval *tv = NULL; + struct timeval *tvp, tv; int ret, have_records = 1; lwfds = *wfds; + tvp = NULL; if (!dsts_online) { dprintf("writer applying select timeout"); - tv = malloc(sizeof(struct timeval)); - bzero(tv, sizeof(struct timeval)); - tv->tv_sec = 1; + tv.tv_sec = 1; + tv.tv_usec = 0; + tvp = &tv; } - ret = select(FD_SETSIZE, NULL, &lwfds, NULL, tv); + ret = select(FD_SETSIZE, NULL, &lwfds, NULL, tvp); if (ret == -1) { if (errno == EINTR) return;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200804121558.m3CFwRKq079552>