From owner-freebsd-audit Sun Jan 30 19:10:35 2000 Delivered-To: freebsd-audit@freebsd.org Received: from alcanet.com.au (mail.alcanet.com.au [203.62.196.10]) by hub.freebsd.org (Postfix) with ESMTP id DFD9614E1F for ; Sun, 30 Jan 2000 19:10:30 -0800 (PST) (envelope-from jeremyp@gsmx07.alcatel.com.au) Received: by border.alcanet.com.au id <115225>; Mon, 31 Jan 2000 14:11:02 +1100 Content-return: prohibited From: Peter Jeremy Subject: Re: sort, revised patch In-reply-to: ; from mheffner@mailandnews.com on Sat, Jan 29, 2000 at 11:24:29AM +1100 To: Mike Heffner Cc: freebsd-audit@FreeBSD.ORG Message-Id: <00Jan31.141102est.115225@border.alcanet.com.au> MIME-version: 1.0 X-Mailer: Mutt 1.0i Content-type: text/plain; charset=us-ascii References: Date: Mon, 31 Jan 2000 14:11:02 +1100 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On 2000-Jan-29 11:24:29 +1100, Mike Heffner wrote: > Here's the revised patch, it keeps the original naming scheme for >tempfiles, but puts them in a dir made with mkdtemp(3). Looks much better. >- char *name = xmalloc (len + 1 + sizeof ("sort") - 1 + 5 + 5 + 1); >+ char *name; ... >+ temp_dir = xmalloc( len + 1 + strlen(DIR_TEMPLATE) + 1 ); ... >+ name = xmalloc(strlen(temp_dir) + 1 + strlen("sort") + 5 + 5 + 1); Why the change from sizeof() to strlen()? The major advantage of sizeof() is that it is evaluated at compile time. If you stay with sizeof(), you get: >- char *name = xmalloc (len + 1 + sizeof ("sort") - 1 + 5 + 5 + 1); >+ char *name = xmalloc (len + 1 + sizeof(DIR_TEMPLATE) + 1 + sizeof("sort") >+ - 1 + 5 + 5 + 1); and >+ temp_dir = xmalloc( len + 1 + sizeof(DIR_TEMPLATE) ); Peter To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message