* @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. */
| 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. |
nothing calls this directly
no test coverage detected