MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / operator_new_impl

Function operator_new_impl

system/lib/libcxx/src/new.cpp:30–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28// that define non-weak copies of the functions.
29
30static 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);

Callers 3

operator newFunction · 0.70
operator new[]Function · 0.70

Calls 2

get_new_handlerFunction · 0.70
mallocFunction · 0.50

Tested by

no test coverage detected