From owner-p4-projects@FreeBSD.ORG Sat Apr 12 15:58:28 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id E03C71065675; Sat, 12 Apr 2008 15:58:27 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A65A5106564A for ; Sat, 12 Apr 2008 15:58:27 +0000 (UTC) (envelope-from csjp@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 915FD8FC17 for ; Sat, 12 Apr 2008 15:58:27 +0000 (UTC) (envelope-from csjp@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m3CFwRQj079554 for ; Sat, 12 Apr 2008 15:58:27 GMT (envelope-from csjp@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m3CFwRKq079552 for perforce@freebsd.org; Sat, 12 Apr 2008 15:58:27 GMT (envelope-from csjp@freebsd.org) Date: Sat, 12 Apr 2008 15:58:27 GMT Message-Id: <200804121558.m3CFwRKq079552@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to csjp@freebsd.org using -f From: "Christian S.J. Peron" To: Perforce Change Reviews Cc: Subject: PERFORCE change 139902 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Apr 2008 15:58:28 -0000 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;