[sword-devel] SwordReader - Progress

David Trotz dtrotzjr at readingplanner.com
Sun Mar 16 21:09:56 MST 2008

I have spent the weekend restructuring some of the SwordReader code.

I removed the UString stuff and implemented a more elegant replacement 
called WCString. WCString can convert (typically implicitly) from const 
char*, const wchar_t *, and std::string. This will make string 
manipulations between the sword api and the wince api much easier to 
deal with as well as read.

I ran "Code Snitch" (a memory and resource leak detection software) 
against the current source code and eliminated all known memory and 
resource leaks in the gui. I did spot a couple of minor memory leaks in 
the sword api. I cannot verify for sure that they are in fact memory 
leaks but I can say thus far when code snitch detects a memory leak it 
has yet to be wrong, even when I was sure it was wrong. I will try to 
take a stab at fixing these later this week but if anyone recognizes 
these and has an "oh yeah, I forgot about that..." moment feel free to 
take these on. Of course these might be memory leaks in the context of 
my gui source code, but I will point them out anyway.

char *stdstr(char **ipstr, const char *istr, unsigned int memPadFactor) {
    if (istr) {
        if (*ipstr)
            delete [] *ipstr;
        int len = strlen(istr) + 1;
       // the following line has been tagged as a memory leak
        *ipstr = new char [ len * memPadFactor ];
        memcpy(*ipstr, istr, len);
    return *ipstr;

SWKey *VerseKey::clone() const
    // the following line has been tagged as a memory leak
    // probably someone forgot clone creates a new object
    // on the heap
    return new VerseKey(*this);

After spending the time I have in the SwordReader internals, I am making 
plans to restructure more of the source code to make it a bit more 
intuitive and approachable. Once this is done I will introduce my new 
html renderer.

Thanks everyone for your prayers and encouragement. They have paid off.
In Christ,
David Trotz

More information about the sword-devel mailing list