| 28 | // that define non-weak copies of the functions. |
| 29 | |
| 30 | static void* operator_new_impl(std::size_t size) { |
| 31 | if (size == 0) |
| 32 | size = 1; |
| 33 | void* p; |
| 34 | while ((p = std::malloc(size)) == nullptr) { |
| 35 | // If malloc fails and there is a new_handler, |
| 36 | // call it to try free up memory. |
| 37 | std::new_handler nh = std::get_new_handler(); |
| 38 | if (nh) |
| 39 | nh(); |
| 40 | else |
| 41 | break; |
| 42 | } |
| 43 | return p; |
| 44 | } |
| 45 | |
| 46 | _LIBCPP_OVERRIDABLE_FUNCTION(void*, operator new, (std::size_t size)) _THROW_BAD_ALLOC { |
| 47 | void* p = operator_new_impl(size); |
no test coverage detected