Paul Eggert <address@hidden
> schrieb am Sa., 21. Nov. 2015 um 01:28 Uhr:
Philipp Stephani wrote:
> Why, that's how malloc also behaves.
Yes, of course. But this part of malloc's behavior is so painful that Emacs code
typically never invokes malloc directly; it uses xmalloc, which is guaranteed to
return non-null. Many modules will have needs similar to Emacs itself in that
respect, and it would be better if they didn't have to reinvent this so-common
But what should the interface be? There are only three possibilities in C: return a sentinel value, crash, longjmp. Crashing prevents modules from doing their own error handling or degrading gracefully. longjmp is not possible in general because arbitrary C (and especially C++) code isn't prepared for it. So the sentinel value is the only option. This is also consistent with all the other environment functions that return a pointer.