On Thu, Aug 11, 2016 at 4:51 AM, Slava Imameyev <[email protected]>
wrote:

> Calling retain() before function call and release() after is redundant and
> even might point to synchronization problems in the design.
>

Calling that pattern redundant seems like a stretch. I'm not familiar with
the code in question, but if you're implying that the command gate retains
its owner, then that's incorrect. If you're implying that an object will
automatically be retained while running one of its methods, that's also
incorrect, even for Objective-C/ARC.

Unless the calling code guarantees the opposite, the owner of a command
gate can be destroyed (retain count reaches 0) while the command gate is
waiting for the lock to become available, or busy running the action. In
most cases, you'd expect this to cause a kernel panic or worse, memory
corruption, in the action being run.

Whether the retain/release are placed correctly I can't say without taking
a deep dive in the code and understanding the context. You normally want to
try to retain as soon as you acquire the reference, so calling retain on
'this' is maybe suspect - but probably not redundant.

Hope that helps.

Phil
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Usb mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/usb/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to