News for hackers. Stuff that matters.
Re:The abominable strtok() by tptacek on Friday September 24, 2010 @08:34PM (#1725939)
Your allocation failure strategy is orthogonal to how individual allocations should be handled. In a UI program, keep a reserve of memory, return valid addresses to the caller, and pop up a warning.

It's actually easier to do things like this if you aren't hand-crafting individual little alloc-check-handle routines.

Re:The abominable strtok() by __david__ on Friday September 24, 2010 @11:06PM (#1726175)
That seems full of edge cases. If your reserve isn't big enough it doesn't help and if it's too big then it's a waste. It seems much cleaner to be able to gracefully abort whatever operation you were doing. Presumably there is already error handling for fs/network errors. Usually you can hop onto those handlers with memory errors and be just fine.

Though if it's linux it'll just kill you anyway :-). (Yeah, I know you can turn the OOM killer off).