Search code examples
c++c++11unique-ptrlibevent

event_base* vs unique_ptr<event_base>


The code I'm developing tries to avoid handling bare pointers, but I want to add some event based functinalities to it - I would use smart pointers here too, but as I understand it, this would mean that event_base will be deleted using delete operator instead of event_base_free, as in all examples I've seen so far. Is this safe? Can I just use unique_ptr(event_base_new()) and not worry about it?


Solution

  • std::unique_ptr allows you to specify a deleter, so you can find a way to use your event_base_ deletion mechanism.