Subj : Re: malloc() To : borland.public.cpp.borlandcpp From : Bruce Salzman Date : Thu Jun 24 2004 07:21 pm > Do not forget the main discussion: > I had: > txtBuf = (char *)malloc( strlen( szInput ) + 1 ); // with problems > now and then > > I made > txtBuf = (char *)malloc( strlen( szInput ) + 2 ); // no problems in > the last 6 month > > In the last case malloc() seems to work fine! > To my opinion malloc is working but for unknow reasons in the first > construction it takes the wrong size. > The bottom line is that your fix is hiding an error in your program. It may work for now or another 6 months. Or it may fail the next time it runs. Until you track down the cause, you'll never be sure. Regards, Bruce .