mirror of https://github.com/ArduPilot/ardupilot
AP_Terrain: leave ENABLE as 1 if memory alloc fails
This commit is contained in:
parent
d790fe2241
commit
758cb6e942
|
@ -376,7 +376,7 @@ void AP_Terrain::log_terrain_data()
|
|||
*/
|
||||
bool AP_Terrain::allocate(void)
|
||||
{
|
||||
if (enable == 0) {
|
||||
if (enable == 0 || memory_alloc_failed) {
|
||||
return false;
|
||||
}
|
||||
if (cache != nullptr) {
|
||||
|
@ -384,13 +384,11 @@ bool AP_Terrain::allocate(void)
|
|||
}
|
||||
cache = (struct grid_cache *)calloc(TERRAIN_GRID_BLOCK_CACHE_SIZE, sizeof(cache[0]));
|
||||
if (cache == nullptr) {
|
||||
enable.set(0);
|
||||
gcs().send_text(MAV_SEVERITY_CRITICAL, "Terrain: Allocation failed");
|
||||
memory_alloc_failed = true;
|
||||
return false;
|
||||
}
|
||||
cache_size = TERRAIN_GRID_BLOCK_CACHE_SIZE;
|
||||
memory_alloc_failed = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue