Fixed wrong length calculation for memmove. This should at least fix bug #314 and probably more yet unknown problems with ReplaceData(). Also optimized removing data from the end of the buffer.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17101 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
f775a1fea7
commit
eef8149582
@ -1379,8 +1379,8 @@ BMessage::_ResizeData(int32 offset, int32 change)
|
||||
if (change > 0) {
|
||||
if (fHeader->data_available >= change) {
|
||||
if (offset < fHeader->data_size) {
|
||||
ssize_t length = fHeader->data_size - offset;
|
||||
memmove(fData + offset + change, fData + offset, length);
|
||||
memmove(fData + offset + change, fData + offset,
|
||||
fHeader->data_size - offset);
|
||||
}
|
||||
|
||||
fHeader->data_available -= change;
|
||||
@ -1398,14 +1398,16 @@ BMessage::_ResizeData(int32 offset, int32 change)
|
||||
|
||||
if (offset < fHeader->data_size) {
|
||||
memmove(fData + offset + change, fData + offset,
|
||||
fHeader->data_size - offset - change);
|
||||
fHeader->data_size - offset);
|
||||
}
|
||||
|
||||
fHeader->data_size += change;
|
||||
fHeader->data_available = size - fHeader->data_size;
|
||||
} else {
|
||||
ssize_t size = fHeader->data_size;
|
||||
memmove(fData + offset, fData + offset - change, size - offset + change);
|
||||
ssize_t length = fHeader->data_size - offset + change;
|
||||
if (length > 0)
|
||||
memmove(fData + offset, fData + offset - change, length);
|
||||
|
||||
fHeader->data_size += change;
|
||||
fHeader->data_available -= change;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user