Can I free memory passed to SysAllocString?

Posted by RichAmberale on Stack Overflow See other posts from Stack Overflow or by RichAmberale
Published on 2010-04-20T17:04:04Z Indexed on 2010/04/20 17:13 UTC
Read the original article Hit count: 302

Filed under:
|
|
|
|

When allocating a new BSTR with SysAllocString via a wchar_t* on the heap, should I then free the original wchar_t* on the heap?

So is this the right way?

wchar_t *hs = new wchar_t[20];
// load some wchar's into hs...
BSTR bs = SysAllocString(hs);
delete[] hs;

Am I supposed to call delete here to free up the memory? Or was that memory just adoped by the BSTR?

© Stack Overflow or respective owner

Related posts about c++

Related posts about Windows