From owner-freebsd-audit Sun Jan 30 19:36: 7 2000 Delivered-To: freebsd-audit@freebsd.org Received: from MailAndNews.com (MailAndNews.com [199.29.68.160]) by hub.freebsd.org (Postfix) with ESMTP id 9662414D12 for ; Sun, 30 Jan 2000 19:36:04 -0800 (PST) (envelope-from mheffner@mailandnews.com) Received: from muriel.penguinpowered.com [208.138.198.103] (mheffner@mailandnews.com); Sun, 30 Jan 2000 22:35:54 -0500 X-WM-Posted-At: MailAndNews.com; Sun, 30 Jan 00 22:35:54 -0500 Content-Length: 1371 Message-ID: X-Mailer: XFMail 1.4.4 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <00Jan31.141102est.115225@border.alcanet.com.au> Date: Sun, 30 Jan 2000 22:37:27 -0500 (EST) Reply-To: Mike Heffner From: Mike Heffner To: Peter Jeremy Subject: Re: sort, revised patch Cc: freebsd-audit@FreeBSD.ORG, Mike Heffner Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On 31-Jan-2000 Peter Jeremy wrote: | On 2000-Jan-29 11:24:29 +1100, Mike Heffner | wrote: |>- 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. well, because with sizeof it'll give you the len+1, and then you have to subtract one (if you want to be exact). eg: sizeof("blahblah") = 9 whereas strlen("blahblah") = 8 sizeof() would work if you wanted it to include the null... i guess some it was personal habit as well. i can change it back. | | 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 + ^ -1 | sizeof("sort") - 1 + 5 + 5 + 1); | | and | |>+ temp_dir = xmalloc( len + 1 + sizeof(DIR_TEMPLATE) ); | | Peter --------------------------------- Mike Heffner Fredericksburg, VA ICQ# 882073 Date: 30-Jan-2000 Time: 22:22:55 --------------------------------- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message