Issue 294: Check for allocation failure
Add statistics for allocation failures

This patch adds a new stat "malloc_fails" that is a counter of how
many times malloc/realloc/calloc returned NULL when we _needed_ it to
return something else (resulting in closing the connection or something
like that). Conditions where we could live without malloc returning
a new chunk of memory is not tracked with this counter.
Fix tests again..