Re: GetBuffer Problem
Hi Everyone,
Here it goes:
void CMyObj::ReplaceStringsInList(BOOL bIsExpression, CString& s,
CStringList&, CStringList&)
{
LPTSTR aux;
try{
aux = s.GetBuffer(256 * 1024 + 1);
}catch(CException *e){
aux = NULL;
TCHAR sz[255];
_stprintf(sz, _T("%d"), errno);
TRACE1("%s", sz);
}
if( aux != NULL ){
::DoReplaceStrings(bIsExpression, CString((LPCTSTR)s), aux );
s.ReleaseBuffer();
}
}
I didn't have the try catch before, and it was blewing up my
application. I do a lot of calls because I want to change a property
inside a object in a collection that may itself have another object
collection and so on. If the propertys have the same value, this value
is replaced by the new one. It's a pretty complex model. But the
recursion is fine, there is no circular dependency. Something weird
also happened when I was debbuging. When I did it step by step on the
interation that was not allocating memory, it didn't raise a exception
and allocated memory fine. That's why I started to get suspicious
about the frequency of allocation as the source of the problem, but I
couldn't find any documentation about it.
Thanks
Marcos