I am looking at the documentation of IOBufferMemoryDescriptor
. It says "... Except where noted, you are also responsible for releasing buffers that you allocate.".
IOBufferMemoryDescriptor::free
also exists. My questions is: should I use free
or release
(or maybe both) to do the cleanup?
free()
is called automatically when the last handle is dropped usingOSSafeReleaseNULL
. (This callsrelease()
internally, but it's usually best to use the macro.)So, never call the
free()
method directly, you only need to care about it in the context of overriding it in your own subclasses. Always use the reference counting mechanism onOSObject
-derived classes.