Fix reporting VK_ERROR_OUT_OF_HOST_MEMORY
Fix reporting VK_ERROR_OUT_OF_HOST_MEMORY

The regular C++ operator new calls the installed new-handler on
out-of-memory, which by default throws std::bad_alloc when exception
handling is enabled, or aborts when not. Under no circumstance is null
returned. Furthermore, LLVM installs a new-handler itself, which also
ends up aborting the program.

Using the std::nothrow version of new does not work because it still
calls the new-handler. Installing our own non-fatal new-handler is also
futile because the new operator will re-attempt allocation.

Setting the new-handler to nullptr will cause the nothrow version of new
to return null on out-of-memory. However, this still overrides any new
handler which the application may have installed, or, can be overridden
by the application again at any point.

Instead just use legacy malloc(), which is guaranteed to never throw and
returns null on failure. This is already checked for by vk::Create() and
it reports VK_ERROR_OUT_OF_HOST_MEMORY.

Bug: b/137093675
Change-Id: I6c9ccf738cfd21af9e52382d6e7755071d613d39
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/34028
Presubmit-Ready: Nicolas Capens <51edc787c30f24c4904e8ffbb5523c3a9f7a451d@google.com>
Reviewed-by: Ben Clayton <1f693eb7158dc33015048c09d6712f74dabddf79@google.com>
Reviewed-by: Chris Forbes <c3279c50043e18e9442c1ae071cafa0e7a4ca967@google.com>
Tested-by: Nicolas Capens <51edc787c30f24c4904e8ffbb5523c3a9f7a451d@google.com>
Kokoro-Presubmit: kokoro <2ac7b1f3fa578934c95181d4272be0d3bca00121@google.com>

bkaradzic/SwiftShader,google/swiftshader,bkaradzic/SwiftShader,google/swiftshader,google/swiftshader,bkaradzic/SwiftShader,bkaradzic/SwiftShader,bkaradzic/SwiftShader