diff --git a/libraries/AP_Filesystem/AP_Filesystem.cpp b/libraries/AP_Filesystem/AP_Filesystem.cpp index 63f575bb5b..c780c5a9b1 100644 --- a/libraries/AP_Filesystem/AP_Filesystem.cpp +++ b/libraries/AP_Filesystem/AP_Filesystem.cpp @@ -208,7 +208,7 @@ AP_Filesystem::DirHandle *AP_Filesystem::opendir(const char *pathname) } const Backend &backend = backend_by_path(pathname); - DirHandle *h = new DirHandle; + DirHandle *h = NEW_NOTHROW DirHandle; if (!h) { return nullptr; } diff --git a/libraries/AP_Filesystem/AP_Filesystem_FATFS.cpp b/libraries/AP_Filesystem/AP_Filesystem_FATFS.cpp index ba47b60c74..c234779d05 100644 --- a/libraries/AP_Filesystem/AP_Filesystem_FATFS.cpp +++ b/libraries/AP_Filesystem/AP_Filesystem_FATFS.cpp @@ -706,7 +706,7 @@ void *AP_Filesystem_FATFS::opendir(const char *pathdir) CHECK_REMOUNT_NULL(); debug("Opendir %s", pathdir); - struct DIR_Wrapper *ret = new DIR_Wrapper; + struct DIR_Wrapper *ret = NEW_NOTHROW DIR_Wrapper; if (!ret) { return nullptr; } diff --git a/libraries/AP_Filesystem/AP_Filesystem_Mission.cpp b/libraries/AP_Filesystem/AP_Filesystem_Mission.cpp index cba03addcd..28c1ea1b0e 100644 --- a/libraries/AP_Filesystem/AP_Filesystem_Mission.cpp +++ b/libraries/AP_Filesystem/AP_Filesystem_Mission.cpp @@ -70,7 +70,7 @@ int AP_Filesystem_Mission::open(const char *fname, int flags, bool allow_absolut r.num_items = get_num_items(r.mtype); if (!readonly) { // setup for upload - r.writebuf = new ExpandingString(); + r.writebuf = NEW_NOTHROW ExpandingString(); } else { r.writebuf = nullptr; } @@ -464,7 +464,7 @@ bool AP_Filesystem_Mission::finish_upload_fence(const struct header &hdr, const // passing nullptr and 0 items through to Polyfence loader is // absolutely OK: if (hdr.num_items != 0) { - new_items = new AC_PolyFenceItem[hdr.num_items]; + new_items = NEW_NOTHROW AC_PolyFenceItem[hdr.num_items]; if (new_items == nullptr) { GCS_SEND_TEXT(MAV_SEVERITY_WARNING, "Out of memory for upload"); goto OUT; diff --git a/libraries/AP_Filesystem/AP_Filesystem_Param.cpp b/libraries/AP_Filesystem/AP_Filesystem_Param.cpp index d29efe8f9d..31a53acc0d 100644 --- a/libraries/AP_Filesystem/AP_Filesystem_Param.cpp +++ b/libraries/AP_Filesystem/AP_Filesystem_Param.cpp @@ -50,7 +50,7 @@ int AP_Filesystem_Param::open(const char *fname, int flags, bool allow_absolute_ } struct rfile &r = file[idx]; if (read_only) { - r.cursors = new cursor[num_cursors]; + r.cursors = NEW_NOTHROW cursor[num_cursors]; if (r.cursors == nullptr) { errno = ENOMEM; return -1; @@ -66,7 +66,7 @@ int AP_Filesystem_Param::open(const char *fname, int flags, bool allow_absolute_ r.writebuf = nullptr; if (!read_only) { // setup for upload - r.writebuf = new ExpandingString(); + r.writebuf = NEW_NOTHROW ExpandingString(); if (r.writebuf == nullptr) { close(idx); errno = ENOMEM; diff --git a/libraries/AP_Filesystem/AP_Filesystem_ROMFS.cpp b/libraries/AP_Filesystem/AP_Filesystem_ROMFS.cpp index f1aa5d69d9..eb562694a8 100644 --- a/libraries/AP_Filesystem/AP_Filesystem_ROMFS.cpp +++ b/libraries/AP_Filesystem/AP_Filesystem_ROMFS.cpp @@ -245,7 +245,7 @@ bool AP_Filesystem_ROMFS::set_mtime(const char *filename, const uint32_t mtime_s */ FileData *AP_Filesystem_ROMFS::load_file(const char *filename) { - FileData *fd = new FileData(this); + FileData *fd = NEW_NOTHROW FileData(this); if (!fd) { return nullptr; } diff --git a/libraries/AP_Filesystem/AP_Filesystem_Sys.cpp b/libraries/AP_Filesystem/AP_Filesystem_Sys.cpp index 9eadd7f607..7efa34db0b 100644 --- a/libraries/AP_Filesystem/AP_Filesystem_Sys.cpp +++ b/libraries/AP_Filesystem/AP_Filesystem_Sys.cpp @@ -83,7 +83,7 @@ int AP_Filesystem_Sys::open(const char *fname, int flags, bool allow_absolute_pa return -1; } struct rfile &r = file[idx]; - r.str = new ExpandingString; + r.str = NEW_NOTHROW ExpandingString; if (r.str == nullptr) { errno = ENOMEM; return -1; @@ -229,7 +229,7 @@ void *AP_Filesystem_Sys::opendir(const char *pathname) errno = ENOENT; return nullptr; } - DirReadTracker *dtracker = new DirReadTracker; + DirReadTracker *dtracker = NEW_NOTHROW DirReadTracker; if (dtracker == nullptr) { errno = ENOMEM; return nullptr; diff --git a/libraries/AP_Filesystem/AP_Filesystem_backend.cpp b/libraries/AP_Filesystem/AP_Filesystem_backend.cpp index 342eac4dbd..db1eb97075 100644 --- a/libraries/AP_Filesystem/AP_Filesystem_backend.cpp +++ b/libraries/AP_Filesystem/AP_Filesystem_backend.cpp @@ -29,7 +29,7 @@ FileData *AP_Filesystem_Backend::load_file(const char *filename) if (stat(filename, &st) != 0) { return nullptr; } - FileData *fd = new FileData(this); + FileData *fd = NEW_NOTHROW FileData(this); if (fd == nullptr) { return nullptr; } diff --git a/libraries/AP_Filesystem/posix_compat.cpp b/libraries/AP_Filesystem/posix_compat.cpp index 6dee4f1653..f29e70fe80 100644 --- a/libraries/AP_Filesystem/posix_compat.cpp +++ b/libraries/AP_Filesystem/posix_compat.cpp @@ -70,7 +70,7 @@ static int posix_fopen_modes_to_open(const char *mode) APFS_FILE *apfs_fopen(const char *pathname, const char *mode) { - APFS_FILE *f = new APFS_FILE; + APFS_FILE *f = NEW_NOTHROW APFS_FILE; if (!f) { return nullptr; }