Re: Assigning a BSTR to a CString
One possibility for the failure is that your process doesn't
have an available block of contiguous virtual addresses to
satisfy your allocation request. This is caused by memory
fragmentation. Another possibility is that MFC cannot
allocate large blocks due to using non-zero max heap
size in HeapCreate (I'm not familiar with MFC so this
may not be an issue).
I'd suggest you rewrite the interface of your processing
function to accept LPCWSTR instead of a CString, or
even a BSTR.
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@mvps.org
MVP VC FAQ: http://vcfaq.mvps.org
=====================================
"Jorge Yanez" <Jorge@nospam.com> wrote in message
news:Of3FdVU%23HHA.4200@TK2MSFTNGP04.phx.gbl...
Hi Giovanni and Sven, and thanks you both for the reply
You are right, I'm using XML through MSXML, but is in the other way: I
create a DOM Document and then I get the XML into a BSTR.
After that, I try to move the string from the CComBSTR to my variable
CString to use it as parameter in a call to a method of another class that
will store the CString content in a database.
I will try the approach using "new" or maybe there is a way to transfer
the buffer from the BSTR to the CString. But aside the workarounds, I
still have the doubt about what is the reason for the crash...
Jorge.
"SvenC" <svenc@community.nospam> escribi? en el mensaje
news:86BCA8F7-9745-4D54-BCF2-BE371145A7BF@microsoft.com...
Hi,
I think the problem may be the large block of memory that you are
requesting...
Just a test: have you tried to allocate it via new?
Maybe you could write ad-hoc code to copy such very big strings...
Or you could partition your big string into smaller substrings and maybe
chain them together using a linked-list...
Or avoid copying altogether and store the BSTR directly. Seems more
efficient to me anyways.
I would assume that later on you hand the xml string (the name strXML
indicates that you are passing an XML string around, right?) to a parser
like MSXML you will need to convert back from CString to BSTR.
--
SvenC