Hi everyone,
I have a question about the function parserutils_buffer_discard.
As i understand, it is meant to "discard" some data from the buffer :
---------------------------------------------------------------
| |xxxx| |
| |xxxx| |
|---------------------------------------------------------------
s--------------------------------o-------l------------------->
s being start, o offset, and length, the amount of bytes to disard.
The memmove being done is :
memmove(buffer->data + offset, buffer->data + offset + len, buffer->length - len);
I wonder why you would move more data than what's left in the buffer ?
As i understand the situation, there is buffer->length-(offset+len) bytes left, my question is, why not do this :
memmove(buffer->data + offset, buffer->data + offset + len, buffer->length - (offset + len));
Thanks in advance for your responses,
Regards,
adema
No comments:
Post a Comment