[haiku-development] BNetBuffer odd members name

  • From: Christophe Huriaux <c.huriaux@xxxxxxxxx>
  • To: haiku-development <haiku-development@xxxxxxxxxxxxx>
  • Date: Tue, 6 Jul 2010 21:27:49 +0200

Hi devs,

 While using the BNetBuffer class to hold incoming data from a BNetEndpoint,
I faced a problem regarding to the few members giving buffer size
informations :
    - BNetBuffer::Size() should (according to the BeBook), "return the
number of bytes currently in the buffer.". Actually, if we look at the
source code (in src/kits/network/libnetapi/DynamicBuffer.cpp :: Size() ) it
returns the allocated buffer size (i.e including unused bytes at the end and
wasted bytes at the beginning of the buffer).

    - BNetBuffer::BytesRemaining() should "return the number of unused bytes
in the buffer." while it returns the number of used bytes in the buffer
(this is what Size() should do).

 Please correct me if I'm wrong, but I believe the members bodies doesn't
correspond to the right member names (e.g: DynamicBuffer::Size() should
return fDataEnd - fDataStart and DynamicBuffer::BytesRemaining() should
return fBufferSize - fDataEnd, since "remaining" bytes are located in the
end of the buffer)

 Note that it would also explain ticket #4724, which have been resolved in
r33437 by replacing the Size() call by BytesRemaining().

 I didn't find any information stating that the meaning of those members had
changed in Haiku, that's why I preferred to ask here for comments before
opening a ticket. The patch is fairly easy to write though, but what about
apps which used this workaround (i.e: replacing Size() by BytesRemaining() )
in order to work fine ?

Best regards,
Christophe Huriaux

Other related posts: