3 ms·
It returns NULL to indicate errors? Not any platform I've used lately. The Linux man page is in fact explicit that it never returns NULL: RETURN VALUE
by BeeOnRope 8y ago
It returns NULL to indicate errors? Not any platform I've used lately.
The Linux man page is in fact explicit that it never returns NULL:
RETURN VALUE
The alloca() function returns a pointer to the
beginning of the allocated space. If the
allocation causes stack overflow, program behavior
is undefined.
NOTES
...
The inlined code often consists of a single
instruction adjusting the stack pointer, and
does not check for stack overflow. Thus, there
is no NULL error return.
As a practical matter it is difficult for an implementation to have alloca return an error value even if they wanted to: it would be both two slow and in some cases "impossible" to know ahead of time in the same way that malloc is unlikely to return null on some systems.