MCPcopy Create free account
hub / github.com/DanielChappuis/reactphysics3d / allocate

Method allocate

include/reactphysics3d/containers/Stack.h:62–86  ·  view source on GitHub ↗

Allocate more memory

Source from the content-addressed store, hash-verified

60
61 /// Allocate more memory
62 void allocate(uint64 capacity) {
63
64 // Make sure capacity is an integral multiple of alignment
65 capacity = std::ceil(capacity / float(GLOBAL_ALIGNMENT)) * GLOBAL_ALIGNMENT;
66
67 T* newArray = static_cast<T*>(mAllocator.allocate(capacity * sizeof(T)));
68 assert(newArray != nullptr);
69
70 // If there
71 if (mCapacity > 0) {
72
73 if (mNbElements > 0) {
74
75 // Copy the previous items in the new array
76 std::uninitialized_copy(mArray, mArray + mNbElements, newArray);
77 }
78
79 // Release memory of the previous array
80 mAllocator.release(mArray, mCapacity * sizeof(T));
81 }
82
83 mArray = newArray;
84
85 mCapacity = capacity;
86 }
87
88 public:
89

Callers 10

insertMethod · 0.45
MapMethod · 0.45
reserveMethod · 0.45
MapClass · 0.45
StackMethod · 0.45
reserveMethod · 0.45
reserveMethod · 0.45
SetMethod · 0.45
reserveMethod · 0.45
SetClass · 0.45

Calls 1

releaseMethod · 0.45

Tested by

no test coverage detected