硫酸钾肥:对数据进行udp封装时,出现内存泄漏,怎么办?

来源:百度文库 编辑:神马品牌网 时间:2024/05/06 06:58:22
我在用蓝牙的硬件模块实现数据的传输,在不进行UDP封装时,数据能传输,可封装后,就老是出现内存泄漏的指示,望能得到解答: unsigned char buff[120];
unsigned char *pointto=buff;
// unsigned char *pointtoo=buff;
// addip(data);
// _CrtDumpMemoryLeaks();
ip_pack ip_hdr;
udp_pack udp_hdr;
int iTotalSize=0;
iTotalSize=sizeof(ip_hdr)+sizeof(udp_hdr)+92;
ip_hdr.ip_verlen=69;
ip_hdr.ip_tos=0;
ip_hdr.ip_totallength=iTotalSize;
ip_hdr.ip_id=0;
ip_hdr.ip_ttl=128;
ip_hdr.ip_protocol=0x11;
ip_hdr.ip_scraddr=FromIP;
ip_hdr.ip_destaddr=ToIP;
int iUdpSize=0;
iUdpSize=sizeof(udp_hdr)+92;
udp_hdr.udp_sport=FromPort;
udp_hdr.udp_dport=ToPort;
udp_hdr.udp_len=iUdpSize;
udp_hdr.udp_checksum=0;
ZeroMemory(buff,120);
_CrtDumpMemoryLeaks();
//pointto=buff;
memcpy(pointto,&ip_hdr,sizeof(ip_hdr)); pointto+=sizeof(ip_hdr);
memcpy(pointto,&udp_hdr,sizeof(udp_hdr)); pointto+=sizeof(udp_hdr);
memcpy(pointto,data2,92);
_CrtDumpMemoryLeaks();
BCP_SendData(bt_device[i].dlc[j].dlc_handle,(UINT8 *)buff,120);//发送函数

说句实话,这个问题真不该在这里发表,应该去技术论坛!