[En-Nut-Discussion] Netbuff freeing

Harald Kipp harald.kipp at egnite.de
Sun Jul 20 17:24:07 CEST 2003


>
>I suggest that the code that creates an outgoing net buffer  should always
>be responsible for freeing it. This means that calling a send function will
>*never* free the buffer.

I'm afraid, but it's not that easy. :-(

Almost any function claims, that a NETBUF is released in
case an error occurs. One reason is, that NutNetBufAlloc()
returns a NULL pointer if it fails to allocate a NETBUF
part. The whole NETBUF is released in this case.

Most errors occure because of low memory and thus it makes
sense to early release as much heap space as possible.

Anyway, NutUdpSendTo() is indeed buggy. A NETBUF should
not be released if the lower level routine returns an error.
I'll correct this.

Harald 




More information about the En-Nut-Discussion mailing list