mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-11 02:18:29 -04:00
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)
|
bool AP_Terrain::allocate(void)
|
||||||
{
|
{
|
||||||
if (enable == 0) {
|
if (enable == 0 || memory_alloc_failed) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (cache != nullptr) {
|
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]));
|
cache = (struct grid_cache *)calloc(TERRAIN_GRID_BLOCK_CACHE_SIZE, sizeof(cache[0]));
|
||||||
if (cache == nullptr) {
|
if (cache == nullptr) {
|
||||||
enable.set(0);
|
|
||||||
gcs().send_text(MAV_SEVERITY_CRITICAL, "Terrain: Allocation failed");
|
gcs().send_text(MAV_SEVERITY_CRITICAL, "Terrain: Allocation failed");
|
||||||
memory_alloc_failed = true;
|
memory_alloc_failed = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
cache_size = TERRAIN_GRID_BLOCK_CACHE_SIZE;
|
cache_size = TERRAIN_GRID_BLOCK_CACHE_SIZE;
|
||||||
memory_alloc_failed = false;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user