Skip to content

Commit 5263292

Browse files
When computing new cursor window allocation size, add additional 1/10th of initial buffer
1 parent e33556d commit 5263292

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

jni/CursorWindow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ uint32_t CursorWindow::alloc(size_t requestedSize, bool aligned)
143143
if (size > freeSpace()) {
144144
LOGE("need to grow: mSize = %d, size = %d, freeSpace() = %d, numRows = %d",
145145
mSize, size, freeSpace(), mHeader->numRows);
146-
new_allocation_sz = mSize + size - freeSpace();
146+
new_allocation_sz = mSize + size - freeSpace() + GROW_WINDOW_SIZE_EXTRA;
147147
tempData = realloc((void *)mData, new_allocation_sz);
148148
if(tempData == NULL) return 0;
149149
mData = (uint8_t *)tempData;

jni/CursorWindow.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535

3636
#define ROW_SLOT_CHUNK_NUM_ROWS 16
3737

38+
#define GROW_WINDOW_SIZE_EXTRA MAX_WINDOW_SIZE / 10
39+
3840
// Row slots are allocated in chunks of ROW_SLOT_CHUNK_NUM_ROWS,
3941
// with an offset after the rows that points to the next chunk
4042
#define ROW_SLOT_CHUNK_SIZE ((ROW_SLOT_CHUNK_NUM_ROWS * sizeof(row_slot_t)) + sizeof(uint32_t))

0 commit comments

Comments
 (0)