AP_NavEKF: allow init twice
this can happen if setup_core() fails with low mem and is called again
This commit is contained in:
parent
1e4b1d7563
commit
fe81387433
@ -14,6 +14,9 @@ ekf_ring_buffer::ekf_ring_buffer(uint8_t _elsize) :
|
|||||||
|
|
||||||
bool ekf_ring_buffer::init(uint8_t size)
|
bool ekf_ring_buffer::init(uint8_t size)
|
||||||
{
|
{
|
||||||
|
if (buffer) {
|
||||||
|
free(buffer);
|
||||||
|
}
|
||||||
buffer = calloc(size, elsize);
|
buffer = calloc(size, elsize);
|
||||||
if (buffer == nullptr) {
|
if (buffer == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
@ -141,6 +144,10 @@ void *ekf_imu_buffer::get_offset(uint8_t idx) const
|
|||||||
// initialise buffer, returns false when allocation has failed
|
// initialise buffer, returns false when allocation has failed
|
||||||
bool ekf_imu_buffer::init(uint32_t size)
|
bool ekf_imu_buffer::init(uint32_t size)
|
||||||
{
|
{
|
||||||
|
if (buffer != nullptr) {
|
||||||
|
// allow for init twive
|
||||||
|
free(buffer);
|
||||||
|
}
|
||||||
buffer = calloc(size, elsize);
|
buffer = calloc(size, elsize);
|
||||||
if (buffer == nullptr) {
|
if (buffer == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user