MCPcopy Create free account
hub / github.com/Tessil/ordered-map / allocate

Method allocate

tests/custom_allocator_tests.cpp:65–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63 const_pointer address(const_reference x) const noexcept { return &x; }
64
65 pointer allocate(size_type n, const void* /*hint*/ = 0) {
66 nb_custom_allocs++;
67
68 pointer ptr = static_cast<pointer>(std::malloc(n * sizeof(T)));
69 if (ptr == nullptr) {
70#ifdef TSL_OH_NO_EXCEPTIONS
71 std::abort();
72#else
73 throw std::bad_alloc();
74#endif
75 }
76
77 return ptr;
78 }
79
80 void deallocate(T* p, size_type /*n*/) { std::free(p); }
81

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected