2014-05-15 03:18:55 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2008 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <new>
|
2016-05-27 02:35:00 +02:00
|
|
|
|
|
|
|
#include <errno.h>
|
2014-05-15 03:18:55 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2014-05-31 01:00:53 +02:00
|
|
|
#include "private/libc_logging.h"
|
|
|
|
|
2014-05-15 03:18:55 +02:00
|
|
|
const std::nothrow_t std::nothrow = {};
|
|
|
|
|
|
|
|
void* operator new(std::size_t size) {
|
|
|
|
void* p = malloc(size);
|
|
|
|
if (p == NULL) {
|
2014-05-31 01:00:53 +02:00
|
|
|
__libc_fatal("new failed to allocate %zu bytes", size);
|
2014-05-15 03:18:55 +02:00
|
|
|
}
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
void* operator new[](std::size_t size) {
|
|
|
|
void* p = malloc(size);
|
|
|
|
if (p == NULL) {
|
2014-05-31 01:00:53 +02:00
|
|
|
__libc_fatal("new[] failed to allocate %zu bytes", size);
|
2014-05-15 03:18:55 +02:00
|
|
|
}
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
2014-08-25 21:08:19 +02:00
|
|
|
void operator delete(void* ptr) throw() {
|
2014-05-15 03:18:55 +02:00
|
|
|
free(ptr);
|
|
|
|
}
|
|
|
|
|
2014-08-25 21:08:19 +02:00
|
|
|
void operator delete[](void* ptr) throw() {
|
2014-05-15 03:18:55 +02:00
|
|
|
free(ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void* operator new(std::size_t size, const std::nothrow_t&) {
|
|
|
|
return malloc(size);
|
|
|
|
}
|
|
|
|
|
|
|
|
void* operator new[](std::size_t size, const std::nothrow_t&) {
|
|
|
|
return malloc(size);
|
|
|
|
}
|
|
|
|
|
2014-08-25 21:08:19 +02:00
|
|
|
void operator delete(void* ptr, const std::nothrow_t&) throw() {
|
2014-05-15 03:18:55 +02:00
|
|
|
free(ptr);
|
|
|
|
}
|
|
|
|
|
2014-08-25 21:08:19 +02:00
|
|
|
void operator delete[](void* ptr, const std::nothrow_t&) throw() {
|
2014-05-15 03:18:55 +02:00
|
|
|
free(ptr);
|
|
|
|
}
|