Preallocate dma edge counter array
We can only ever have 4 edge counters due to hardware limits, so let's
just use a sized array.
Change-Id: I07fe7c27b64f2c0878cdc9844dbd304fa7f94d48
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/frc971/wpilib/dma_edge_counting.h b/frc971/wpilib/dma_edge_counting.h
index d8fe476..b645d01 100644
--- a/frc971/wpilib/dma_edge_counting.h
+++ b/frc971/wpilib/dma_edge_counting.h
@@ -7,6 +7,7 @@
#include "aos/macros.h"
+#include "aos/containers/sized_array.h"
#include "frc971/wpilib/dma.h"
#include "frc971/wpilib/ahal/AnalogInput.h"
@@ -239,7 +240,7 @@
// Start().
void Add(DMASampleHandlerInterface *handler) {
handler->AddToDMA(dma_.get());
- handlers_.emplace_back(handler);
+ handlers_.push_back(handler);
}
// Actually starts watching for DMA samples.
@@ -266,7 +267,7 @@
void CheckDMA();
const ::std::unique_ptr<DMA> dma_;
- ::std::vector<DMASampleHandlerInterface *> handlers_;
+ aos::SizedArray<DMASampleHandlerInterface *, 4> handlers_;
// The time at which we most recently read the sensor values.
int64_t sample_time_ = 0;