util-buffer: expand by multiples of 4k

This commit is contained in:
Jason Ish
2024-11-28 21:28:30 +01:00
committed by Victor Julien
parent 2e2eaac0b2
commit 287d8360e7
+5
View File
@@ -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);