libgit2/libgit2 — pull request #2080 by ethomson (2014-01-27 18:36:18+00:00)
Title: void *malloc(size_t) -> int malloc(void **, size_t)

This was an exercise in discovering whether we could / should change the allocators to fit more with the standards we use for other things - returning an `int` status code and taking a pointer that will be set to the allocated memory. I'm pushing this up more for discussion, at the moment, to see if we even want to continue down this path.

Note that I did this on win32 so it's pretty likely that Travis won't even build this successfully. Also, I broke blame, so the tests there will fail miserably at the moment.

I think this was very valuable as a learning experience, as it required me to touch every allocation throughout the library. My takeaway is that switching us over to free memory in the event of an allocation failure would generally not be ridiculously burdensome.

Additional takeaways:

1. We are good about checking the return codes from `*alloc`, generally. (Yay!) There were a few that we must have simply overlooked, but there was only one area that was systematically poor,.
2. Blame needs some better error handling.
3. `git_oid__fmtz` should probably exist, at least as an internal helper.

However, this didn't provide nearly the value that I had hoped. In fact, I would say that it's an overall negative since there are now more unfun compiler warnings.

Anyway. I did want to push this up for the sake of discussion, but I think that we should abandon this effort and keep `malloc` sane. Certainly we should go fix up the problem areas that I noticed, though.