MCPcopy Create free account
hub / github.com/Duet3D/RepRapFirmware / THROWS

Function THROWS

src/Platform/ArrayHandle.cpp:23–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21
22// Allocate space for an array and initialise its elements to null expressions
23void ArrayHandle::Allocate(size_t numElements) THROWS(GCodeException)
24{
25#if CHECK_HEAP_LOCKED
26 Heap::heapLock.CheckHasWriteLock();
27#endif
28 Heap::IndexSlot * const slot = Heap::AllocateHandle();
29 Heap::StorageSpace * const space = Heap::AllocateSpace(sizeof(ArrayStorageSpace) + numElements * sizeof(ExpressionValue));
30 slot->storage = space;
31 if (space->length < sizeof(ArrayStorageSpace) + numElements * sizeof(ExpressionValue))
32 {
33 Heap::DeleteSlot(slot);
34 throw GCodeException("Array too large");
35 }
36
37 ArrayStorageSpace * const aSpace = reinterpret_cast<ArrayStorageSpace*>(space);
38 aSpace->count = numElements;
39 for (size_t i = 0; i < numElements; ++i)
40 {
41 new (&aSpace->elements[i]) ExpressionValue;
42 }
43 slotPtr = slot;
44}
45
46// Assign an element without making the array unique first
47void ArrayHandle::AssignElement(size_t index, ExpressionValue &val) THROWS(GCodeException)

Callers

nothing calls this directly

Calls 3

GetNumElementsMethod · 0.80
GCodeExceptionClass · 0.50
GetTypeMethod · 0.45

Tested by

no test coverage detected