MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / makeStorage

Method makeStorage

app/src/DSP.h:298–312  ·  view source on GitHub ↗

* @brief Allocates the backing array, pinning plot-scale buffers into physical memory. The * deleter owns the unpin, so shared copies / snapshots / resize stay leak-free. */

Source from the content-addressed store, hash-verified

296 * deleter owns the unpin, so shared copies / snapshots / resize stay leak-free.
297 */
298 [[nodiscard]] static std::shared_ptr<T[]> makeStorage(std::size_t n)
299 {
300 Q_ASSERT(n > 0);
301
302 T* data = new T[n];
303 const std::size_t bytes = n * sizeof(T);
304 if (bytes >= kPinThresholdBytes && Platform::AppPlatform::lockMemoryResident(data, bytes)) {
305 return std::shared_ptr<T[]>(data, [bytes](T* p) {
306 Platform::AppPlatform::unlockMemoryResident(p, bytes);
307 delete[] p;
308 });
309 }
310
311 return std::shared_ptr<T[]>(data);
312 }
313
314 /**
315 * @brief Computes the storage index where the next element will be inserted.

Callers

nothing calls this directly

Calls 2

lockMemoryResidentFunction · 0.85
unlockMemoryResidentFunction · 0.85

Tested by

no test coverage detected