PERFORCE change 139902 for review
Christian S.J. Peron
csjp at FreeBSD.org
Sat Apr 12 15:58:28 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=139902
Change 139902 by csjp at 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;
More information about the p4-projects
mailing list