[haiku-development] Re: DeskCalc Improvements (was need strtold() function)

  • From: John Scipione <jscipione@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Thu, 31 Dec 2009 11:40:05 -0500

On Thu, Dec 31, 2009 at 10:47 AM, Ingo Weinhold <ingo_weinhold@xxxxxx> wrote:
>
> On 2009-12-31 at 14:50:44 [+0100], John Scipione <jscipione@xxxxxxxxx> wrote:
>> On Thu, Dec 31, 2009 at 7:32 AM, Ingo Weinhold <ingo_weinhold@xxxxxx> wrote:
>> >
>> > On 2009-12-31 at 10:01:31 [+0100], Stephan Assmus <superstippi@xxxxxx>
>> > wrote:
>> >> Thanks for your work! Can you post another version where you use spaces
>> >> instead of tabs? (Maybe it's just an editor setting?)
>> >
>> > Er, tabs instead of spaces. Already "tasted" the New Year's Eve punch? ;-)
>
>> I converted tabs to spaces.
>
> No, please use tabs as our coding style guide requires. Stephan seemed to be
> somewhat confused suggesting otherwise.
>
>> I put a space after the while and if
>> statements. I changed decimalPlaces to be a uint32 instead of an int32
>> and took out the check about decimalPlaces being < 0. I didn't quite
>> understand what you were trying to say about the allocation check
>> being "copy&paste left-over" but in my defense I didn't write that
>> code, I just moved it.
>
> What Stephan was referring to:
>
> +    char buffer[decimalPlaces + 15];
> +    value.toString(buffer, decimalPlaces);
> +    if (buffer == NULL)
> +        throw ParseException("out of memory", 0);
>
> buffer cannot be NULL, since it is allocated on the stack.
>
> CU, Ingo
>
>

Gotcha, tabs not spaces (that is what I thought). Buffer cannot be
NULL that is my fault sorry. My thinking in writing the NULL check was
that I wanted to check if you don't have enough memory to make a char
buffer[decimalPlaces + 15]. I mean, if decimalPlaces is set to MAX_INT
than that is ~32k of memory which is sort of a lot.

John Scipione

Other related posts: