Re: memory leakage in vc++ 6.0
sirisha wrote:
am trying to develop an application to transfer a folder of files
using sockets.
rsync and possibly FTP already do that, why reinvent the wheel?
bWorking=finder.FindFile(_T((LPCTSTR)findFilePath));
What the hell are you doing here? You shouldn't be casting things around
like this and the _T macro should only be used in combination with string
literals....
long fileSize;
long is not long enough. Further, you could use the win32 API to get the
size of the file in a much more elegant way.
fileContentBuffer = (char*)calloc(32,sizeof(long));
Use static_cast.
if(returnValue == SOCKET_ERROR)
{
cout<<endl<<"Error in Sending File Length";
CloseSocket();
return;
}
else
cout<<endl<<"File Size Sent Successfully : "<<fileSize;
free(fileContentBuffer);
In case of an error, you fail to release allocated storage. You should
research the RAII idiom of C++ (or use std::vector right away).
Uli