File tree 1 file changed +16
-0
lines changed 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -492,6 +492,22 @@ template <typename T, typename U>
492
492
inline v8::MaybeLocal<v8::Value> ToV8Value (v8::Local<v8::Context> context,
493
493
const std::unordered_map<T, U>& map);
494
494
495
+ // Helper for `malloced_unique_ptr`
496
+ template <typename T>
497
+ struct MallocDeleter {
498
+ void operator ()(T* ptr) const { free (ptr); }
499
+ };
500
+
501
+ // Specialization of `std::unique_ptr` that used `Malloc<t>`
502
+ template <typename T>
503
+ using malloced_unique_ptr = std::unique_ptr<T, MallocDeleter<T>>;
504
+
505
+ // Factory of `malloced_unique_ptr`
506
+ template <typename T>
507
+ malloced_unique_ptr<T> make_malloced_unique (size_t number_of_t ) {
508
+ return malloced_unique_ptr<T>(Malloc<T>(number_of_t ));
509
+ }
510
+
495
511
} // namespace node
496
512
497
513
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
You can’t perform that action at this time.
0 commit comments