1 /* 2 ** 3 ** Copyright 2017, The Android Open Source Project 4 ** 5 ** Licensed under the Apache License, Version 2.0 (the "License"); 6 ** you may not use this file except in compliance with the License. 7 ** You may obtain a copy of the License at 8 ** 9 ** http://www.apache.org/licenses/LICENSE-2.0 10 ** 11 ** Unless required by applicable law or agreed to in writing, software 12 ** distributed under the License is distributed on an "AS IS" BASIS, 13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 ** See the License for the specific language governing permissions and 15 ** limitations under the License. 16 */ 17 18 #include <keymaster/new> 19 #include <stdlib.h> 20 21 namespace std { 22 struct nothrow_t {}; 23 } 24 25 extern const std::nothrow_t __attribute__((weak)) std::nothrow = {}; 26 operator new(size_t __sz,const std::nothrow_t &)27void* __attribute__((weak)) operator new(size_t __sz, const std::nothrow_t&) { 28 return malloc(__sz); 29 } operator new[](size_t __sz,const std::nothrow_t &)30void* __attribute__((weak)) operator new[](size_t __sz, const std::nothrow_t&) { 31 return malloc(__sz); 32 } 33 operator delete(void * ptr)34void __attribute__((weak)) operator delete(void* ptr) { 35 if (ptr) 36 free(ptr); 37 } 38 operator delete[](void * ptr)39void __attribute__((weak)) operator delete[](void* ptr) { 40 if (ptr) 41 free(ptr); 42 } 43 44 extern "C" { __cxa_pure_virtual()45void __attribute__((weak)) __cxa_pure_virtual() { 46 abort(); 47 } 48 } 49