bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-grep] length of dec. representation of a number


From: Stepan Kasal
Subject: Re: [bug-grep] length of dec. representation of a number
Date: Fri, 25 Feb 2005 07:55:40 +0100
User-agent: Mutt/1.4.1i

Hi Julian,

On Thu, Feb 24, 2005 at 03:57:34PM +0000, Julian Foad wrote:
> > get_nondigit_option (int argc, char *const *argv, int *default_context)
> > {
> >   int opt;
> >-  char buf[sizeof (uintmax_t) * CHAR_BIT + 4];
> >+  char buf[(sizeof(uintmax_t) + 1) / 2 * 5 + 4];  /* log_10(2^16) < 5 */
> 
> If you're optimising the buffer size, there's something else you should do. 
> Here, the result is going to be stored in *default_context, an "int".  
> There's no point in allowing a number as big as "uintmax_t".  [...]

Yes, you are right, we should do
  char buf[INT_BUFSIZE_BOUND(*default_context) + 3];  /* 3 dots when we give up 
*/

Stepan Kasal




reply via email to

[Prev in Thread] Current Thread [Next in Thread]