[sword-devel] SwordReader - Progress report...

David Trotz dtrotzjr at crosswire.org
Mon Mar 17 19:27:18 MST 2008


I found the leaks and they were in SwordReader's search code. There was 
a call to VerseKey::clone which returns a pointer to a SWKey, which was 
then being implicitly cast back into a VerseKey object, and the 
anonymous object was lost in the transaction. This also cleared the 
stdstr leak as well which I assume had to do with the lost SWKey.

Also I have implemented a better progress bar in SwordReader's search, 
it actually updates by passing SWModule::search's call back argument. It 
now updates regularly.

--
In Christ,
David Trotz

David Trotz wrote:
> 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.
>
> <utilstr.cpp>
> 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;
> }
> </utilstr.cpp>
>
> <versekey.cpp>
> 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);
> }
> </versekey.cpp>
>
> 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
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> sword-devel mailing list: sword-devel at crosswire.org
> http://www.crosswire.org/mailman/listinfo/sword-devel
> Instructions to unsubscribe/change your settings at above page

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.crosswire.org/pipermail/sword-devel/attachments/20080317/4acb0f06/attachment.html 


More information about the sword-devel mailing list