File tree Expand file tree Collapse file tree 3 files changed +14
-4
lines changed Expand file tree Collapse file tree 3 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -475,7 +475,7 @@ void rw_range_sett::add(
475
475
entry->second =util_make_unique<range_domaint>();
476
476
477
477
static_cast <range_domaint&>(*entry->second ).push_back (
478
- std::make_pair ( range_start, range_end) );
478
+ { range_start, range_end} );
479
479
}
480
480
481
481
void rw_range_sett::get_objects_rec (
@@ -678,7 +678,7 @@ void rw_guarded_range_set_value_sett::add(
678
678
entry->second =util_make_unique<guarded_range_domaint>();
679
679
680
680
static_cast <guarded_range_domaint&>(*entry->second ).insert (
681
- std::make_pair ( range_start, std::make_pair ( range_end, guard.as_expr ())) );
681
+ { range_start, { range_end, guard.as_expr ()}} );
682
682
}
683
683
684
684
void goto_rw (goto_programt::const_targett target,
Original file line number Diff line number Diff line change @@ -109,7 +109,7 @@ class rw_range_sett
109
109
110
110
const range_domaint &get_ranges (objectst::const_iterator it) const
111
111
{
112
- assert (dynamic_cast <range_domaint*>(it->second .get ()));
112
+ PRECONDITION (dynamic_cast <range_domaint*>(it->second .get ())!= nullptr );
113
113
return static_cast <const range_domaint &>(*it->second );
114
114
}
115
115
@@ -278,7 +278,8 @@ class rw_guarded_range_set_value_sett:public rw_range_set_value_sett
278
278
279
279
const guarded_range_domaint &get_ranges (objectst::const_iterator it) const
280
280
{
281
- assert (dynamic_cast <guarded_range_domaint*>(it->second .get ())!=nullptr );
281
+ PRECONDITION (
282
+ dynamic_cast <guarded_range_domaint*>(it->second .get ())!=nullptr );
282
283
return static_cast <const guarded_range_domaint &>(*it->second );
283
284
}
284
285
Original file line number Diff line number Diff line change 12
12
#include < cstdlib>
13
13
#include < utility>
14
14
15
+ // / A functor wrapping `std::free`. Can be used as the deleter of a unique_ptr
16
+ // / to free memory originally allocated by `std::malloc`. This is primarily
17
+ // / useful for interfacing with C APIs in a memory-safe way.
18
+ // / Note that the approach of using an empty functor as a unique_ptr deleter
19
+ // / does not impose any space overhead on the unique_ptr instance, whereas
20
+ // / using a function-pointer as the deleter requires the unique_ptr to store
21
+ // / this function pointer internally, effectively doubling the size of the
22
+ // / object. Therefore, `std::unique_ptr<T, freert>` should be preferred to
23
+ // / `std::unique_ptr<T, decltype(&std::free)>`.
15
24
struct freert
16
25
{
17
26
template <typename T>
You can’t perform that action at this time.
0 commit comments