[En-Nut-Discussion] Bug Report
Mike Cornelius
mikec at call-direct.com.au
Mon Jan 19 01:12:45 CET 2004
Hi Oliver,
I thought about that and thought that the dwonside was wasting memory
lets say the buffer size was say 1K and got "resized" to 4 byte?
Regards,
Mike
-----Original Message-----
From: en-nut-discussion-bounces at egnite.de
[mailto:en-nut-discussion-bounces at egnite.de] On Behalf Of Oliver Schulz
Sent: Friday, January 16, 2004 6:53 PM
To: Ethernut User Chat (English)
Subject: AW: [En-Nut-Discussion] Bug Report
Hi Mike,
thanks for finding this bug.
I think the first intention of not reallocating smaller buffer sizes is
not to waste time for over and over releasing and reserving heap memory
again.
But of course, if just a smaller buffer size is needed, the nb_XX.sz
must be adjusted to the smaller buffer.
For every buffer type I will add an else part to set the correct
nb_XX.sz value.
It's right now in CVS.
Cheers,
Oliver.
-----Ursprüngliche Nachricht-----
Von: Mike Cornelius [mailto:mikec at call-direct.com.au]
Gesendet: Freitag, 16. Januar 2004 06:56
An: en-Nut-Discussion at Egnite. De
Betreff: [En-Nut-Discussion] Bug Report
Hi All,
I have found a bug in NutNetBufAlloc() netbuf.c
In a number of places there are lines like :-
if (nb->nb_XX.sz < size)
If the condition is true (ie the buffer is too small) the old memory
block is returned to the heap and a new one assigned nb->nb_XX.sz is
updated to reflect the new size and all is OK.
However if the new requested size is smaller than the existing size then
nothing happens. This is a problem because nb->nb_XX.sz does not get
updated to reflect the new smaller size and sometime later on when the
network dirver goes to send this packet it sends too many bytes.
I've changed the code to if (nb->nb_XX.sz !< size)...
Which works for me but there may be a better way...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
Mike Cornelius Internet: mikec at call-direct.com.au
Call Direct Cellular Solutions Phone: +61 2 9209-4259
Suite 145 FAX: +61 2 9209-4196
National Innovation Centre URL: http://www.call-direct.com.au
Australian Technology Park
Eveleigh NSW 1430
Australia
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
_______________________________________________
En-Nut-Discussion mailing list
En-Nut-Discussion at egnite.de
http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion
More information about the En-Nut-Discussion
mailing list