Home > Back-end >  Shall the caller deallocate the return value of `SHCreateMemStream`?
Shall the caller deallocate the return value of `SHCreateMemStream`?

Time:02-01

This is a dumb question, but I'm sorry I cannot find this information in the online manual of the function. I came from Linux realm. I'm not familiar with convention in Windows world.

All examples I found use smart pointer, e.g. wil::com_ptr, but GCC obviously doesn't provide those tools. Shall I call Release on the return value? Or leave it alone? Thanks.

CodePudding user response:

IStream is built on top of the classic COM IUnknown interface, and as such any pointer returned from a function has IUnknown::AddRef called on it and you must call IUnknown::Release when you're done or you'll leak memory.

GCC obviously doesn't provide those tools

Just in case you needed a reason to use cl on Windows and the Windows SDK, you found it.

  •  Tags:  
  • Related