新手上路 
 
	- 积分
 - 31
 
        - 金钱
 - 31 
 
       - 注册时间
 - 2019-8-12
 
      - 在线时间
 - 8 小时
 
 
 
 | 
 
 
发表于 2020-2-26 15:31:00
|
显示全部楼层
 
 
 
关于这个问题  偶尔出现的提示为:Assertion "mem_free: legal memory" failed at line 323 in ..\LWIP\lwip-1.4.1\src\core\mem.c 
 在程序里面是static err_t tcp_echoclient_connected(void *arg, struct tcp_pcb *tpcb, err_t err) 
{ 
  struct echoclient *        es = NULL; 
  #ifdef LWIP_TCP_DEBUG 
        printf("\r\n connected 开始 ");  
        #endif 
  if (err == ERR_OK)    
  {  
    /* allocate structure es to maintain tcp connection informations */ 
                myes = (struct echoclient *)mem_malloc(sizeof(struct echoclient)); //注意这个是采用mem_malloc来分配的 
 
其对应的释放是采用 static void tcp_echoclient_connection_close(struct tcp_pcb *tpcb, struct echoclient * es ) 
{ 
  /* remove callbacks */ 
        tcp_recv(tpcb, NULL); 
  tcp_sent(tpcb, NULL); 
  tcp_poll(tpcb, NULL,0); 
 
  if (es != NULL) 
  { 
    mem_free(es); //采用LWIP的内存释放  
  } 
如果你采用了原子哥的内存分配 myes = (struct echoclient *)mymalloc(SRAMIN,sizeof(struct echoclient)); 
 对应的mem_free也需要采用原子哥的  
 |   
 
 
 
 |