[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] to free or not to free (pbuf_free in tcp_recv)
From: |
goldsimon |
Subject: |
Re: [lwip-users] to free or not to free (pbuf_free in tcp_recv) |
Date: |
Wed, 23 Jan 2019 15:42:29 +0100 |
User-agent: |
K-9 Mail for Android |
Am 23. Januar 2019 15:05:06 MEZ schrieb address@hidden:
>Hi,
>
>I'm working with the lwIP 1.4.1 on a TI M4 platform with rawapi and I'm
>having trouble to understand the documentation correctly.
>In particular the callback for tcp_recv(). In the rawapi.txt is said
>
>"If there are no errors and the callback function is to return ERR_OK,
>then
>it must free the pbuf.
>Otherwise, it must not free the pbuf so that lwIP core code can store
>it."
>
>But in the echo example there is this part:
>echo_recv() {
>...
>else if(err != ERR_OK)
> {
> /* cleanup, for unkown reason */
> if (p != NULL)
> {
> es->p = NULL;
> pbuf_free(p);
> }
> ret_err = err;
> }
>
>The pbuf is freed AND the callback function returns an error. What
>would
>happen with the pbuf if it is not freed?
Try updating to a more recent version. Besides getting so many bugs fixed,
you'll see that the echo code has changed as well since 1.4.1...
Regards,
Simon