Re: ref count
Well, of course... :) I was talking about explicit aliasing,
however. This implicit aliasing is mentioned in the COM
spec as a safe optimization for avoiding AddRef/Release
on interface pointers passed to functions/methods.
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@mvps.org
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
"Igor Tandetnik" <itandetnik@mvps.org> wrote in message
news:OnY9KPd5GHA.3404@TK2MSFTNGP03.phx.gbl...
"Alexander Nickolov" <agnickolov@mvps.org> wrote in message
news:%23HbAVXb5GHA.3452@TK2MSFTNGP05.phx.gbl
I should mention of course that aliasing is a dangerous
business and should be avoided if reasonable. In my programming
career I've encountered very few cases this would be useful, and
even then safer techniques were available...
There is a common case: an alias is created every time an interface
pointer is passed as an [in] parameter to a function or method. For the
duration of the called function, there are two copies of the pointer but
the reference count is not incremented. Luckily, the rules require that
the function not Release an [in] parameter, so one of the copies quietly
goes away leaving behind a correct ref count.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925