[asterisk-dev] [Code Review] remove checks for alloca and ast_strdupa NULL return value
Walter Doekes
walter+asterisk-dev at osso.nl
Mon Jul 16 07:36:58 CDT 2012
On 12/07/12 21:00, Simon Perreault wrote:
>> But, I believe the gcc __builtin_alloca guarantees it won't return NULL,
>> but fail in more mysterious ways instead or SEGFAULT. So, I added an
>> ast_alloca macro that expands to that.
>
> What do you think alloca() expands to on FreeBSD?
>
> That's right! __builtin_alloca()!
I wouldn't know. I don't have any BSD boxes.
I'm simply reacting to Tilghman.
> On FreeBSD, for example, it's perfectly possible for alloca() to return NULL.
So, unless someone says that __builtin_alloca() can return NULL on
FreeBSD, then both patch (1) and patch (2) should be OK.
I'd still prefer patch (2), since I read that gcc uses __builtin_alloca
only for -O2 or higher -- we might get a different implementation for
non-optimized builds on certain systems(?).
In addition, the ast_strdupa macro also refers to __builtin_alloca()
directly instead of to alloca(). It then makes sense to not use alloca()
in the rest of the source either.
Regards,
Walter
More information about the asterisk-dev
mailing list