lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] questions on lwip (two TCP/IP sockets)


From: shogun
Subject: [lwip-users] questions on lwip (two TCP/IP sockets)
Date: Thu, 12 Aug 2010 14:19:02 -0400

Thanks for the help it is working much better now!  The comments about
freeing memory is from this thread:

http://e2e.ti.com/support/microcontrollers/stellaris_arm_cortex-m3_microcont
roller/f/471/p/54250/192785.aspx#192785

How do you recommend I free the memory?

----------------------------------------------------------------------

<SNIP>


> static err_t socket_new_recv(void *arg, struct tcp_pcb *pcb, struct pbuf
*p,
> err_t err )
>
> {
[snip]
>                                 ert = pbuf_free(p);
>
>                                 while(p->next) //see if next contains a
non
> NULL pointer
>                                 {
>                                                 ert = pbuf_free(p->next);
>                                                 if(ert)
>                                                 {
>
UARTprintf("
> error (%d) freeing data at %x\n", ert, p->next);
>                                                 }
>                                                 p = p->next;
>                                 }//end clean up memory
>
[snip]
>                                 ert = pbuf_free(p);

You should only be calling pbuf_free once, and if the pbuf is chained,
pbuf_free will chase the chain for you, you do not need to do so.
(And if you did need to chase the chain, it's generally not a good
idea to be looking at a data structure's contents after you've freed
it, as you're doing here.)

Jeff







reply via email to

[Prev in Thread] Current Thread [Next in Thread]