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

Function do_allocate

system/lib/libcxx/src/memory_resource.cpp:42–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40
41class _LIBCPP_HIDDEN __new_delete_memory_resource_imp : public memory_resource {
42 void* do_allocate(size_t bytes, size_t align) override {
43#if _LIBCPP_HAS_ALIGNED_ALLOCATION
44 return std::__libcpp_allocate<std::byte>(__element_count(bytes), align);
45#else
46 if (bytes == 0)
47 bytes = 1;
48 std::byte* result = std::__libcpp_allocate<std::byte>(__element_count(bytes), align);
49 if (!is_aligned_to(result, align)) {
50 std::__libcpp_deallocate<std::byte>(result, __element_count(bytes), align);
51 std::__throw_bad_alloc();
52 }
53 return result;
54#endif
55 }
56
57 void do_deallocate(void* p, size_t bytes, size_t align) override {
58 std::__libcpp_deallocate<std::byte>(static_cast<std::byte*>(p), __element_count(bytes), align);

Callers 1

allocateFunction · 0.85

Calls 2

is_aligned_toFunction · 0.85
__throw_bad_allocFunction · 0.85

Tested by

no test coverage detected