560 Subj : Re: malloc() To : borland.public.cpp.borlandcpp From : Jan Vernimmen Date : Thu Jun 24 2004 08:57 pm Hi Bob, I think I'm going to change the malloc's in the way you suggested using GlobalAlloc and GlobalFree. Of course you are right about the order of allocating and freeing memory, I always try the same. Your scheme translated to my code should like as follows: a=malloc() if( a ) { b=malloc() if( b ) { if ( characters ) { do stuff if ( more characters then strlen(b) ) { free(b) b=malloc() //I must check malloc, -> b=null } copy stuff.str to b } } if( b ) { free(b) b=NULL } free(a) a=NULL } 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. Greetings, Jan. . 0