Re: SysFreeString - Is the memory mine to use as I please ?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance




"Tim Roberts" <timr@xxxxxxxxx> wrote in message news:ndv7l29u0jinn10rtbrg7kim243asod5k3@xxxxxxxxxx
"Egbert Nierop \(MVP for IIS\)" <egbert_nierop@xxxxxxxxxxxxxx> wrote:

the Sys* functions depend on CoTaskMemAlloc and CoTaskMemFree

As you know, BSTR's are compatible with LPWSTR's for use with zero
terminated strings but they are zero prepended.

What???

Typo,
they are length prepended and the total allocation is 16 bytes memory aligned.

A BSTR is an LPWSTR with the length of the string buffer stored in the word
just before the start of the string.

All about this...
http://technolog.nl/blogs/eprogrammer/archive/2006/07/25/Boost-BSTR-performance-for-free_2C00_-by-3000_2500_.aspx

And here is the source to 'replace' BSTR allocation with a faster alternative.
http://technolog.nl/blogs/eprogrammer/archive/2006/03/22/_5B00_Win64_5D00_-My-story_3A00_-Porting-a-product-to-x64.aspx

.