mirror of
https://github.com/TomHarte/CLK.git
synced 2024-09-08 18:55:14 +00:00
Merge pull request #664 from TomHarte/DataAllocationGuards
Adds safety checks around video data allocation
This commit is contained in:
commit
ddae086661
@ -406,6 +406,10 @@ void CRT::set_immediate_default_phase(float phase) {
|
||||
}
|
||||
|
||||
void CRT::output_data(int number_of_cycles, size_t number_of_samples) {
|
||||
#ifndef NDEBUG
|
||||
assert(number_of_samples > 0 && number_of_samples <= allocated_data_length_);
|
||||
allocated_data_length_ = std::numeric_limits<size_t>::min();
|
||||
#endif
|
||||
scan_target_->end_data(number_of_samples);
|
||||
Scan scan;
|
||||
scan.type = Scan::Type::Data;
|
||||
|
@ -10,6 +10,7 @@
|
||||
#define CRT_hpp
|
||||
|
||||
#include <cstdint>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
|
||||
#include "../ScanTarget.hpp"
|
||||
@ -83,6 +84,10 @@ class CRT {
|
||||
Outputs::Display::ScanTarget::Modals scan_target_modals_;
|
||||
static const uint8_t DefaultAmplitude = 80;
|
||||
|
||||
#ifndef NDEBUG
|
||||
size_t allocated_data_length_ = std::numeric_limits<size_t>::min();
|
||||
#endif
|
||||
|
||||
public:
|
||||
/*! Constructs the CRT with a specified clock rate, height and colour subcarrier frequency.
|
||||
The requested number of buffers, each with the requested number of bytes per pixel,
|
||||
@ -221,6 +226,9 @@ class CRT {
|
||||
@returns A pointer to the allocated area if room is available; @c nullptr otherwise.
|
||||
*/
|
||||
inline uint8_t *begin_data(std::size_t required_length, std::size_t required_alignment = 1) {
|
||||
#ifndef NDEBUG
|
||||
allocated_data_length_ = required_length;
|
||||
#endif
|
||||
return scan_target_->begin_data(required_length, required_alignment);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user