mirror of
https://github.com/neovim/neovim.git
synced 2025-10-05 01:16:31 +00:00
vim-patch:9.0.1271: using sizeof() and subtract array size is tricky (#22087)
Problem: Using sizeof() and subtract array size is tricky.
Solution: Use offsetof() instead. (closes vim/vim#11926)
1b438a8228
This commit is contained in:
@@ -3855,7 +3855,7 @@ static void *getroom(spellinfo_T *spin, size_t len, bool align)
|
||||
|
||||
if (bl == NULL || (size_t)bl->sb_used + len > SBLOCKSIZE) {
|
||||
// Allocate a block of memory. It is not freed until much later.
|
||||
bl = xcalloc(1, (sizeof(sblock_T) + SBLOCKSIZE));
|
||||
bl = xcalloc(1, offsetof(sblock_T, sb_data) + SBLOCKSIZE + 1);
|
||||
bl->sb_next = spin->si_blocks;
|
||||
spin->si_blocks = bl;
|
||||
bl->sb_used = 0;
|
||||
|
Reference in New Issue
Block a user