Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microsoft objects, the Release() functions return value?

I'm curious because I couldn't find out about this on MSDN. I've found the Release() function is present in various COM objects which I'm obviously supposed to use for deleting pointers. But I'm not sure what does it return exactly? I used to think it would return the number of references which still exist to the object remaining, therefore something like:

while( pointer->Release() > 0 );

Would obviously release all references to that pointer?

Or am I not seeing something?

*note I'm talking about this from the concept of the IDirect3DTexture9::Release() function

like image 886
meds Avatar asked May 20 '09 15:05

meds


1 Answers

In addition to what Mehrdad said, the return value of Release is intended for debugging purposes only. Production code should just ignore it.

Looping until Release() returns 0 is definitely a bug - you should never release references you don't own.

like image 187
Michael Avatar answered Sep 18 '22 22:09

Michael