Skip to content

Commit

Permalink
Remove new nothrow
Browse files Browse the repository at this point in the history
  • Loading branch information
LinZhihao-723 committed Dec 5, 2024
1 parent aa2d6da commit a5825af
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
4 changes: 1 addition & 3 deletions src/clp_ffi_py/ir/native/PyKeyValuePairLogEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include <cstddef>
#include <cstdint>
#include <new>
#include <optional>
#include <span>
#include <stack>
Expand Down Expand Up @@ -643,8 +642,7 @@ auto decode_as_encoded_text_ast(Value const& val) -> std::optional<std::string>
} // namespace

auto PyKeyValuePairLogEvent::init(clp::ffi::KeyValuePairLogEvent kv_pair_log_event) -> bool {
m_kv_pair_log_event
= new (std::nothrow) clp::ffi::KeyValuePairLogEvent{std::move(kv_pair_log_event)};
m_kv_pair_log_event = new clp::ffi::KeyValuePairLogEvent{std::move(kv_pair_log_event)};
if (nullptr == m_kv_pair_log_event) {
PyErr_SetString(
PyExc_RuntimeError,
Expand Down
4 changes: 1 addition & 3 deletions src/clp_ffi_py/ir/native/PyLogEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

#include "PyLogEvent.hpp"

#include <new>

#include <clp_ffi_py/error_messages.hpp>
#include <clp_ffi_py/ir/native/LogEvent.hpp>
#include <clp_ffi_py/ir/native/PyQuery.hpp>
Expand Down Expand Up @@ -496,7 +494,7 @@ auto PyLogEvent::init(
std::optional<std::string_view> formatted_timestamp
) -> bool {
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
m_log_event = new (std::nothrow) LogEvent(log_message, timestamp, index, formatted_timestamp);
m_log_event = new LogEvent(log_message, timestamp, index, formatted_timestamp);
if (nullptr == m_log_event) {
PyErr_SetString(
PyExc_RuntimeError,
Expand Down
13 changes: 6 additions & 7 deletions src/clp_ffi_py/ir/native/PyQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

#include "PyQuery.hpp"

#include <new>

#include <clp/string_utils/string_utils.hpp>

#include <clp_ffi_py/error_messages.hpp>
Expand Down Expand Up @@ -629,11 +627,12 @@ auto PyQuery::init(
) -> bool {
try {
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
m_query = new (std::nothrow)
Query(search_time_lower_bound,
search_time_upper_bound,
wildcard_queries,
search_time_termination_margin);
m_query = new Query(
search_time_lower_bound,
search_time_upper_bound,
wildcard_queries,
search_time_termination_margin
);
if (nullptr == m_query) {
PyErr_SetString(
PyExc_RuntimeError,
Expand Down
2 changes: 1 addition & 1 deletion src/clp_ffi_py/ir/native/PySerializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ auto PySerializer::init(
) -> bool {
m_output_stream = output_stream;
Py_INCREF(output_stream);
m_serializer = new (std::nothrow) PySerializer::ClpIrSerializer{std::move(serializer)};
m_serializer = new PySerializer::ClpIrSerializer{std::move(serializer)};
m_buffer_size_limit = buffer_size_limit;
if (nullptr == m_serializer) {
PyErr_SetString(
Expand Down

0 comments on commit a5825af

Please sign in to comment.