Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 31 Jan 2000 14:11:02 +1100
From:      Peter Jeremy <peter.jeremy@alcatel.com.au>
To:        Mike Heffner <spock@techfour.net>
Cc:        freebsd-audit@FreeBSD.ORG
Subject:   Re: sort, revised patch
Message-ID:  <00Jan31.141102est.115225@border.alcanet.com.au>
In-Reply-To: <XFMail.20000128192502.mheffner@mailandnews.com>; from mheffner@mailandnews.com on Sat, Jan 29, 2000 at 11:24:29AM %2B1100
References:  <XFMail.20000128192502.mheffner@mailandnews.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2000-Jan-29 11:24:29 +1100, Mike Heffner <mheffner@mailandnews.com> 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?00Jan31.141102est.115225>