commands/ping/pingmodel.cpp
changeset 103 56b6ee983610
parent 0 7f656887cf89
equal deleted inserted replaced
102:6a08c6931c64 103:56b6ee983610
   762 	if (iPacketDataSize > MAX_ICMP_PACKETSIZE)  //Is prevented in .rss file
   762 	if (iPacketDataSize > MAX_ICMP_PACKETSIZE)  //Is prevented in .rss file
   763 		iPacketDataSize = MAX_ICMP_PACKETSIZE;
   763 		iPacketDataSize = MAX_ICMP_PACKETSIZE;
   764 
   764 
   765 	
   765 	
   766 	delete iPacketData;
   766 	delete iPacketData;
       
   767 	iPacketData = NULL;
   767 	iPacketData= HBufC8::NewL(iPacketDataSize + ICMP_HDRLEN); 
   768 	iPacketData= HBufC8::NewL(iPacketDataSize + ICMP_HDRLEN); 
   768 						//Allocates space for the ICMP packet
   769 						//Allocates space for the ICMP packet
   769 	TPtr8 aux(iPacketData->Des());	//weird but necessary. Cannot use Des() directly in iPacket
   770 	TPtr8 aux(iPacketData->Des());	//weird but necessary. Cannot use Des() directly in iPacket
   770 	iPacket.Set(aux);
   771 	iPacket.Set(aux);
   771 	//iPacket.SetMax();	//because it'll be written directly using [] in Compose...() and it would crash.
   772 	//iPacket.SetMax();	//because it'll be written directly using [] in Compose...() and it would crash.
   772 	//HUOM!!! Cannot be SetMax because sometimes the reserved size is slightly bigger. Because of block size?
   773 	//HUOM!!! Cannot be SetMax because sometimes the reserved size is slightly bigger. Because of block size?
   773 	iPacket.SetLength(iPacketDataSize + ICMP_HDRLEN);	//because it'll be written directly using [] in Compose...() and it would crash.
   774 	iPacket.SetLength(iPacketDataSize + ICMP_HDRLEN);	//because it'll be written directly using [] in Compose...() and it would crash.
   774 
   775 
   775 
   776 
   776 	delete iReceivedDataBuffer;
   777 	delete iReceivedDataBuffer;
       
   778 	iReceivedDataBuffer = NULL;
   777 	iReceivedDataBuffer= HBufC8::NewL(iPacketDataSize + ICMP_ECHO_HEADER_SIZE);	//Maximum size of a return packet
   779 	iReceivedDataBuffer= HBufC8::NewL(iPacketDataSize + ICMP_ECHO_HEADER_SIZE);	//Maximum size of a return packet
   778 	TPtr8 auxPtr(iReceivedDataBuffer->Des());	//must be used here because the buffer changes
   780 	TPtr8 auxPtr(iReceivedDataBuffer->Des());	//must be used here because the buffer changes
   779 	iReceivedData.Set(auxPtr);			//we use an aux var because can't use Des() directly Why??
   781 	iReceivedData.Set(auxPtr);			//we use an aux var because can't use Des() directly Why??
   780 	
   782 	
   781 	iConsole->WriteHostL(iHostname);
   783 	iConsole->WriteHostL(iHostname);