This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Usage of Balloc in Newlib


On Nov  6 14:32, Sebastian Huber wrote:
> Hello,
> 
> the Balloc() function can return NULL in case _calloc_r() returns
> NULL.  All users of Balloc() in Newlib don't check for a NULL
> pointer.  Is this Balloc() supposed to never fail?
> 
> ./libc/stdlib/strtod.c:         bd = Balloc(ptr,bd0->_k);
> ./libc/stdlib/strtod.c-         Bcopy(bd, bd0);
> [...]

The code is originally taken from BSD long ago.  You'll still find it in
NetBSD, but a quick check shows that NetBSD now checks for NULL (almost)
throughout.

I guess the question here is if we want to have safe code which checks
for NULL all the time, or if we want to omit the NULL checks to get
faster and smaller code.

I'm not at all opposed to the idea to add these NULL checks if somebody
creates a patch.

I think it's not only the right thing to do, but it's also not really
worth to worry about a few bytes of code size in this floating point
related code.

However, given that I could easily be wrong, it might be worth to hear
other voices...


Corinna

-- 
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]