NVS: Changed all new to new (nothrow)

This commit is contained in:
Jakob Hasse
2019-12-06 14:36:28 +08:00
parent 34fd845242
commit c75ec644f4
10 changed files with 99 additions and 32 deletions
@@ -21,7 +21,7 @@ NVSPartitionManager* NVSPartitionManager::instance = nullptr;
NVSPartitionManager* NVSPartitionManager::get_instance()
{
if (!instance) {
instance = new NVSPartitionManager();
instance = new (std::nothrow) NVSPartitionManager();
}
return instance;
@@ -57,7 +57,10 @@ esp_err_t NVSPartitionManager::init_custom(const char *partName, uint32_t baseSe
Storage* new_storage = NULL;
Storage* storage = lookup_storage_from_name(partName);
if (storage == NULL) {
new_storage = new Storage((const char *)partName);
new_storage = new (std::nothrow) Storage((const char *)partName);
if (!new_storage) return ESP_ERR_NO_MEM;
storage = new_storage;
}
@@ -159,7 +162,10 @@ esp_err_t NVSPartitionManager::open_handle(const char *part_name,
return err;
}
*handle = new NVSHandleSimple(open_mode==NVS_READONLY, nsIndex, sHandle);
*handle = new (std::nothrow) NVSHandleSimple(open_mode==NVS_READONLY, nsIndex, sHandle);
if (!handle) return ESP_ERR_NO_MEM;
nvs_handles.push_back(*handle);
return ESP_OK;