Date: Sun, 30 Jan 2000 22:37:27 -0500 (EST) From: Mike Heffner <mheffner@mailandnews.com> To: Peter Jeremy <peter.jeremy@alcatel.com.au> Cc: freebsd-audit@FreeBSD.ORG, Mike Heffner <spock@techfour.net> Subject: Re: sort, revised patch Message-ID: <XFMail.20000130223727.mheffner@mailandnews.com> In-Reply-To: <00Jan31.141102est.115225@border.alcanet.com.au>
next in thread | previous in thread | raw e-mail | index | archive | help
On 31-Jan-2000 Peter Jeremy wrote: | On 2000-Jan-29 11:24:29 +1100, Mike Heffner <mheffner@mailandnews.com> | 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 <spock@techfour.net> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.20000130223727.mheffner>