Hello,
 
I have a question in regards to CString in usage with MemBufInputSource.
 
Here is an example of my code:
 
DOMDocument* ParseDocument(char *membuffer)
{
   MemBufInputSource *memBufIS = new MemBufInputSource((const XMLByte*)mem, strlen(mem), gMemBufId, false);
   XercesDOMParser *domParser  = new XercesDOMParser;
 
   domParser->parse(*memBufIS);
   return(domParser->getDocument());
}
 
and further down in my code I would have:
void X(CString setting, CString changeval)
{
   X(setting.GetBuffer(0), changeval.GetBuffer(0));
}
 
void X(char *setting, char *changeval)
{
   DOMDocument *foo = ParseDocument(setting);
   DOMDocument *goo = ParseDocument(changeval);
   // do something with the documents...
}
 
The above code becomes a lib file. in my main program, I would
include the lib in my project and have the hpp file included in my
main.cpp file. This becomes an exe.
 
Here is my problem during my testing phase....
void main(int argc, char *argv[]
{
   CString foo = "<valid xml here />\n\
                   <valid xml here/>\n\
                  ....
                 <valid xml here/>";
 
   CString goo = "<valid xml here />\n\
                   <valid xml here/>\n\
                  ....
                 <valid xml here/>";
 
   // this call crashes..
   // foo gets parsed ok, but goo would crash at
   // MemBufInputSource = new MemBufInputSource(...) call...
   X(foo, goo); 
 
   // this call does not crash...
   X(foo.GetBuffer(0), goo.GetBUffer(0)) <-- this would work perfectly...
}
 
Is this caused by my lack of understanding of CString? or is this actually a possible bug with Xerces?
 
Sincerely
-- Jimmy
________________________________________________
The meek shall inherit the earth, but not the mineral rights.
- J. Paul Getty

Reply via email to