am 2f9400b6: Merge "Use __libc_fatal() for failed malloc in new"

* commit '2f9400b679ffe08f7190781e64edda5edf0f7297':
  Use __libc_fatal() for failed malloc in new
This commit is contained in:
Dan Albert 2014-06-03 17:12:16 +00:00 committed by Android Git Automerger
commit 6e5870865e

View File

@ -14,15 +14,18 @@
* limitations under the License.
*/
#include <errno.h>
#include <new>
#include <stdlib.h>
#include "private/libc_logging.h"
const std::nothrow_t std::nothrow = {};
void* operator new(std::size_t size) {
void* p = malloc(size);
if (p == NULL) {
abort();
__libc_fatal("new failed to allocate %zu bytes", size);
}
return p;
}
@ -30,7 +33,7 @@ void* operator new(std::size_t size) {
void* operator new[](std::size_t size) {
void* p = malloc(size);
if (p == NULL) {
abort();
__libc_fatal("new[] failed to allocate %zu bytes", size);
}
return p;
}