1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-27 18:02:17 +03:00

replace new by new (std::nothrow), remove arduino_new

This commit is contained in:
david gauchard
2020-08-17 18:15:45 +02:00
parent 5b3d290de8
commit 6925982284
45 changed files with 207 additions and 167 deletions

View File

@ -203,7 +203,7 @@ int LittleFSImpl::lfs_flash_sync(const struct lfs_config *c) {
#endif
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_LITTLEFS)
FS LittleFS = FS(FSImplPtr(new littlefs_impl::LittleFSImpl(FS_PHYS_ADDR, FS_PHYS_SIZE, FS_PHYS_PAGE, FS_PHYS_BLOCK, FS_MAX_OPEN_FILES)));
FS LittleFS = FS(FSImplPtr(new (std::nothrow) littlefs_impl::LittleFSImpl(FS_PHYS_ADDR, FS_PHYS_SIZE, FS_PHYS_PAGE, FS_PHYS_BLOCK, FS_MAX_OPEN_FILES)));
extern "C" void littlefs_request_end(void)
{

View File

@ -324,7 +324,11 @@ class LittleFSFileImpl : public FileImpl
{
public:
LittleFSFileImpl(LittleFSImpl* fs, const char *name, std::shared_ptr<lfs_file_t> fd, int flags, time_t creation) : _fs(fs), _fd(fd), _opened(true), _flags(flags), _creation(creation) {
_name = std::shared_ptr<char>(new char[strlen(name) + 1], std::default_delete<char[]>());
_name = std::shared_ptr<char>(new (std::nothrow) char[strlen(name) + 1], std::default_delete<char[]>());
if (!_name) {
close();
return;
}
strcpy(_name.get(), name);
}
@ -517,17 +521,26 @@ public:
{
memset(&_dirent, 0, sizeof(_dirent));
if (dirPath) {
_dirPath = std::shared_ptr<char>(new char[strlen(dirPath) + 1], std::default_delete<char[]>());
_dirPath = std::shared_ptr<char>(new (std::nothrow) char[strlen(dirPath) + 1], std::default_delete<char[]>());
if (_dirPath == nullptr) {
close();
return;
}
strcpy(_dirPath.get(), dirPath);
}
}
~LittleFSDirImpl() override {
void close () {
if (_opened) {
lfs_dir_close(_fs->getFS(), _getDir());
_opened = false;
}
}
~LittleFSDirImpl() override {
close();
}
FileImplPtr openFile(OpenMode openMode, AccessMode accessMode) override {
if (!_valid) {
return FileImplPtr();