Skip to content

Commit

Permalink
util-buffer: expand by multiples of 4k
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonish authored and victorjulien committed Nov 28, 2024
1 parent 2e2eaac commit 287d836
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/util-buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ int MemBufferExpand(MemBuffer **buffer, uint32_t expand_by) {
return -1;
}

/* Adjust expand_by to next multiple of 4k. */
if (expand_by % 4096 != 0) {
expand_by = expand_by - (expand_by % 4096) + 4096;
}

size_t total_size = (*buffer)->size + sizeof(MemBuffer) + expand_by;

MemBuffer *tbuffer = SCRealloc(*buffer, total_size);
Expand Down

0 comments on commit 287d836

Please sign in to comment.