mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Merge "Fix: ExtendableBuffer"
This commit is contained in:
commit
210669605a
@ -66,16 +66,17 @@ bool BufferWithExtendableBuffer::writeCodePointsAndAdvancePosition(const int *co
|
|||||||
|
|
||||||
bool BufferWithExtendableBuffer::checkAndPrepareWriting(const int pos, const int size) {
|
bool BufferWithExtendableBuffer::checkAndPrepareWriting(const int pos, const int size) {
|
||||||
if (isInAdditionalBuffer(pos)) {
|
if (isInAdditionalBuffer(pos)) {
|
||||||
if (pos == mUsedAdditionalBufferSize) {
|
const int tailPosition = getTailPosition();
|
||||||
|
if (pos == tailPosition) {
|
||||||
// Append data to the tail.
|
// Append data to the tail.
|
||||||
if (pos + size > static_cast<int>(mAdditionalBuffer.size())) {
|
if (pos + size > static_cast<int>(mAdditionalBuffer.size()) + mOriginalBufferSize) {
|
||||||
// Need to extend buffer.
|
// Need to extend buffer.
|
||||||
if (!extendBuffer()) {
|
if (!extendBuffer()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mUsedAdditionalBufferSize += size;
|
mUsedAdditionalBufferSize += size;
|
||||||
} else if (pos + size >= mUsedAdditionalBufferSize) {
|
} else if (pos + size >= tailPosition) {
|
||||||
// The access will beyond the tail of used region.
|
// The access will beyond the tail of used region.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user