MCPcopy Create free account
hub / github.com/boostorg/asio / allocate

Method allocate

example/cpp11/allocation/server.cpp:45–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43 context_memory& operator=(const context_memory&) = delete;
44
45 void* allocate(std::size_t size, std::size_t align)
46 {
47 // Since this program is single-threaded there is no need to perform any
48 // synchronisation when modifying next_allocation_. Use an atomic or other
49 // form of synchronisation when using an exeution context from multiple
50 // threads.
51 std::size_t space = size + align;
52 if (next_allocation_ + space < preallocated_)
53 {
54 void* ptr = storage_ + next_allocation_;
55 next_allocation_ += space;
56 return std::align(align, size, ptr, space);
57 }
58 else
59 {
60 return ::operator new(size);
61 }
62 }
63
64 void deallocate(void* ptr)
65 {

Callers 2

allocateMethod · 0.45
allocateMethod · 0.45

Calls 2

alignFunction · 0.85
operator newFunction · 0.50

Tested by

no test coverage detected