I have a library that contains a default XML file represented as a const char *
stored byte by byte.
I want the user to be able to request a handle to this file (as a TiXmlDocument).
Currently, I'm trying to do this by passing this string defaultFile
(its defined in its own header file) to TiXmlDocument.Parse()
. The Parse()
is passing me back a garbage pointer (but not null) which causes a crash on an attempt to call SaveFile()
.
I'm able to work around this by writing the same defaultFile
to a file using:
FILE *file;
file = fopen("temp.prme", "w");
fprintf(file, "%s", defaultParameterFile);
fclose(file);
I create a new TiXmlDocument
using the constructor that takes a file path as input. This works, but it's not a real option because I don't want to be saving files to the users machine.
From what I can tell, all the constructor is doing is reading the string from the file, and then sending it straight to the Parse()
. I checked the values that were being passed in memory and found very few differences.
When using the constructor method, you must cal LoadFile()
afterwards. In LoadFile()
, the string being passed to the Parse()
was NOT null terminated. Even though defaultFile
was. Also, all new lines (which in defaultFile
were listed as /r/n
, were listed as \n\n
.
I tried modifying defaultFile
to match what I was seeing from the constructor, and had no luck. Any Suggestions?
For what its worth, defaultFile
is laid out roughly like this:
const char defaultFile[] = {
/* 0x00000000 */ 0x3C, 0x3F, 0x78, 0x6D,
...
};
It's roughly 9000 lines long, with 16 bytes per line.