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

Method GetElement

src/Platform/ArrayHandle.cpp:126–148  ·  view source on GitHub ↗

Retrieve an array element, returning false if the index is out of bounds Caller must have a read lock on heapLock before calling this!

Source from the content-addressed store, hash-verified

124// Retrieve an array element, returning false if the index is out of bounds
125// Caller must have a read lock on heapLock before calling this!
126bool ArrayHandle::GetElement(size_t index, ExpressionValue &rslt) const noexcept
127{
128#if CHECK_HEAP_LOCKED
129 Heap::heapLock.CheckHasReadOrWriteLock();
130#endif
131 if (slotPtr != nullptr)
132 {
133#if CHECK_HANDLES
134 Heap::CheckSlotGood(slotPtr);
135#endif
136 const Heap::StorageSpace *const _ecv_null storage = slotPtr->storage;
137 if (storage != nullptr)
138 {
139 const ArrayStorageSpace *const aSpace = reinterpret_cast<const ArrayStorageSpace*>(_ecv_not_null(storage));
140 if (index < aSpace->count)
141 {
142 rslt = aSpace->elements[index];
143 return true;
144 }
145 }
146 }
147 return false;
148}
149
150// Retrieve the type of an array element, or TypeCode::None if the index is out of range
151// Caller must have a read lock on heapLock before calling this!

Callers 6

AppendAsStringMethod · 0.80
THROWSFunction · 0.80
decreaseFunction · 0.80
THROWSFunction · 0.80
THROWSFunction · 0.80
SetRemoteDriverValuesFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected