From 66360675cf4d091b7460e4a8e1435c13216c1929 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sun, 11 Sep 2022 17:12:44 +0200 Subject: build: allow IWYU to fix includes for all .c files Allow Include What You Use to remove unnecessary includes and only include what is necessary. This helps with reducing compilation times and makes it easier to visualise which dependencies are actually required. Work on https://github.com/neovim/neovim/issues/549, but doesn't close it since this only works fully for .c files and not headers. --- src/nvim/rbuffer.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/nvim/rbuffer.c') diff --git a/src/nvim/rbuffer.c b/src/nvim/rbuffer.c index 2f718e9c2e..dde6e32306 100644 --- a/src/nvim/rbuffer.c +++ b/src/nvim/rbuffer.c @@ -2,15 +2,16 @@ // it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com #include +#include #include #include +#include "nvim/macros.h" #include "nvim/memory.h" #include "nvim/rbuffer.h" -#include "nvim/vim.h" #ifdef INCLUDE_GENERATED_DECLARATIONS -# include "rbuffer.c.generated.h" +# include "rbuffer.c.generated.h" // IWYU pragma: export #endif /// Creates a new `RBuffer` instance. -- cgit From 8ebdb97ea7848b5baf74ee6d9842b0a2e8a0d5fc Mon Sep 17 00:00:00 2001 From: bfredl Date: Sat, 14 Jan 2023 11:34:48 +0100 Subject: fix(rbuffer): handle edge case where write_ptr has wrapped around when using the rbuffer as a linear buffer, exactly filling the buffer will case write_ptr to wrap around too early. For now detect this special case. Of course, the rbuffer should refactored to a proper ring buffer where write_pos >= read_pos always and there is no special case for full buffers. This will be a follow up change. --- src/nvim/rbuffer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/nvim/rbuffer.c') diff --git a/src/nvim/rbuffer.c b/src/nvim/rbuffer.c index dde6e32306..1088dd3778 100644 --- a/src/nvim/rbuffer.c +++ b/src/nvim/rbuffer.c @@ -165,7 +165,8 @@ void rbuffer_consumed_compact(RBuffer *buf, size_t count) assert(buf->read_ptr <= buf->write_ptr); rbuffer_consumed(buf, count); if (buf->read_ptr > buf->start_ptr) { - assert((size_t)(buf->read_ptr - buf->write_ptr) == buf->size); + assert((size_t)(buf->write_ptr - buf->read_ptr) == buf->size + || buf->write_ptr == buf->start_ptr); memmove(buf->start_ptr, buf->read_ptr, buf->size); buf->read_ptr = buf->start_ptr; buf->write_ptr = buf->read_ptr + buf->size; -- cgit