File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -114,14 +114,16 @@ class cpp_function : public function {
114114 object name () const { return attr (" __name__" ); }
115115
116116protected:
117- using unique_function_record = std::unique_ptr<detail::function_record, void (*)(detail::function_record *)>;
117+ struct InitializingFunctionRecordDeleter {
118+ // `destruct(function_record, false)`: `initialize_generic` copies strings and
119+ // takes care of cleaning up in case of exceptions. So pass `false` to `free_strings`.
120+ void operator ()(detail::function_record * rec) { destruct (rec, false ); }
121+ };
122+ using unique_function_record = std::unique_ptr<detail::function_record, InitializingFunctionRecordDeleter>;
118123
119124 // / Space optimization: don't inline this frequently instantiated fragment
120125 PYBIND11_NOINLINE unique_function_record make_function_record () {
121- // `destruct(function_record, false)`: `initialize_generic` copies strings and
122- // takes care of cleaning up in case of exceptions. So set `free_srings` to `false`.
123- auto destruct_no_free_strings = [](detail::function_record * rec) { destruct (rec, false ); };
124- return unique_function_record (new detail::function_record (), destruct_no_free_strings);
126+ return unique_function_record (new detail::function_record ());
125127 }
126128
127129 // / Special internal constructor for functors, lambda functions, etc.
You can’t perform that action at this time.
0 commit comments