void c4_StringArray::SetAt(int nIndex, const char* newElement) { char* s = (char*) _ptrs.GetAt(nIndex); if (s && *s) free(s);
_ptrs.SetAt(nIndex, newElement && *newElement? _strdup(newElement) : "");
}
Hi, to me the if (s && *s) looks suspicious: Imagine you have an empty string: char *p = ""; If you were to say char *q = strdup( p); I am rather certain, that *q == '\0'
If this is true, the condition above will fail for any such string, 'free' wouldn't get called and you'd have a small leak.
Check the allocation in SetAt just below: if the string is an empty string, it does not go through strdup...
Matt wrote:
I ran it through CodeSnitch (Entrek Software, Inc) which indicated that the
app was riddled with small memory leaks. A majority of the reported leaks
have a fairly long call stack, but all end up pointing to strdup in:
I don't know what the memory leaks are, but note that you'd also see this if the entire StringArray never gets cleaned up. It just happens to consist entirely of strdups - so I'd look particularly for leaks of c4_StringArray allocations.
-jcw
_____________________________________________ Metakit mailing list - [EMAIL PROTECTED] http://www.equi4.com/mailman/listinfo/metakit
