|
On 1/05/2015 9:53 PM, 云风 Cloud Wu wrote:
Fair enough. But you'll save a lot of effort debugging your library for OOM checks with an xmalloc wrapper rather than diagnosing a core dump. IMO, better to write your code with error checking from the start even if it's crash-on-failure wrappers which may not cut it for production code.In my experience malloc does fail and quite often when running on a system with constrained memory. I see a lot of code with unchecked mallocs on github and I don't like it. If it's too much effort to check return values why not just wrapper malloc/calloc so OOM failures set a message and exit cleanly?I would like implement the main function first, and then write the details about these checks.