Move alloc func error checking.

Do it all in lws_<alloc func> and just die if we have
a memory allocation failure.  Cleans up the code a bit.