summaryrefslogtreecommitdiffstatshomepage
path: root/src/nvim/memory.h
AgeCommit message (Collapse)AuthorFiles
2025-08-14refactor(build): remove INCLUDE_GENERATED_DECLARATIONS guardsbfredl1
These are not needed after #35129 but making uncrustify still play nice with them was a bit tricky. Unfortunately `uncrustify --update-config-with-doc` breaks strings with backslashes. This issue has been reported upstream, and in the meanwhile auto-update on every single run has been disabled.
2025-06-06refactor: make two functions used only in memory.c static (#34339)zeertzjq1
After #29450 try_to_free_memory() is only used in memory.c. Also move do_outofmem_msg() closer to where it's used.
2025-06-06vim-patch:9.1.1435: completion: various flaws in fuzzy completion (#34335)zeertzjq1
Problem: completion: various flaws in fuzzy completion Solution: fix the issues (Girish Palya) - Remove the brittle `qsort()` on `compl_match_array`. - Add a stable, non-recursive `mergesort` for the internal doubly linked list of matches. - The sort now happens directly on the internal representation (`compl_T`), preserving sync with external structures and making sorting stable. - Update fuzzy match logic to enforce `max_matches` limits after sorting. - Remove `trim_compl_match_array()`, which is no longer necessary. - Fixe test failures by correctly setting `selected` index and maintaining match consistency. - Introduce `mergesort_list()` in `misc2.c`, which operates generically over doubly linked lists. - Remove `pum_score` and `pum_idx` variables fixes: vim/vim#17387 closes: vim/vim#17430 https://github.com/vim/vim/commit/8cd42a58b49c948ab59ced6ca5f5ccfae5d9ecea Co-authored-by: Girish Palya <girishji@gmail.com>
2024-12-23refactor: iwyu #31637Justin M. Keyes1
Result of `make iwyu` (after some "fixups").
2024-06-14Merge pull request #29241 from bfredl/shadapackbfredl1
refactor(shada): use msgpack_sbuffer less
2024-06-11refactor(memory): use builtin strcat() instead of STRCAT()bfredl1
The latter was mostly relevant with the past char_u madness. NOTE: STRCAT also functioned as a counterfeit "NOLINT" for clint apparently. But NOLINT-ing every usecase is just the same as disabling the check entirely.
2024-06-11refactor(shada): use msgpack_sbuffer lessbfredl1
Work towards getting rid of libmsgpack depedency eventually. msgpack_sbuffer is just a string buffer, we can use our own String type.
2024-03-07refactor(msgpack): allow flushing buffer while packing msgpackbfredl1
Before, we needed to always pack an entire msgpack_rpc Object to a continous memory buffer before sending it out to a channel. But this is generally wasteful. it is better to just flush whatever is in the buffer and then continue packing to a new buffer. This is also done for the UI event packer where there are some extra logic to "finish" of an existing batch of nevents/ncalls. This doesn't really stop us from flushing the buffer, just that we need to update the state machine accordingly so the next call to prepare_call() always will start with a new event (even though the buffer might contain overflow data from a large event).
2024-01-25refactor: IWYU (#27186)zeertzjq1
2024-01-11refactor(IWYU): fix headersdundargoc1
Remove `export` pramgas from defs headers as it causes IWYU to believe that the definitions from the defs headers comes from main header, which is not what we really want.
2023-12-21refactor(IWYU): move decor provider types to decoration_defs.h (#26692)zeertzjq1
2023-12-20refactor: eliminate cyclic includesdundargoc1
2023-11-29refactor: move function macros out of vim_defs.h (#26300)zeertzjq1
2023-11-28refactor: fix headers with IWYUdundargoc1
2023-11-27refactor: move Arena and ArenaMem to memory_defs.h (#26240)zeertzjq1
2023-11-12refactor: replace manual header guards with #pragma oncedundargoc1
It is less error-prone than manually defining header guards. Pretty much all compilers support it even if it's not part of the C standard.
2023-10-23build(lint): remove unnecessary clint.py rulesdundargoc1
Uncrustify is the source of truth where possible. Remove any redundant checks from clint.py.
2022-11-15build: allow IWYU to fix includes for all .c filesdundargoc1
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.
2022-11-01build(lint): remove clint.py rules for braces #20880dundargoc1
Uncrustify is the source of truth where possible. Remove any redundant checks from clint.py. See also https://github.com/neovim/neovim/pull/18563
2022-10-31fix(memory): fix memory alignment for dynamic allocationJan Palus1
all pointers returned by arena_alloc residing in arena block should be properly aligned to meet neovim's alignment requirements but keeping it simple settle on ARENA_ALIGN = MAX(sizeof(void *), sizeof(double)).
2022-08-24refactor(arena): use a shared block freelistbfredl1
This is both simpler in client code and more effective (always reuse block hottest in cache)
2022-08-23perf(api): allow to use an arena for return valuesbfredl1
2022-06-20perf(ui): reduce allocation overhead when encoding "redraw" eventsbfredl1
Note for external UIs: Nvim can now emit multiple "redraw" event batches before a final "flush" event is received. To retain existing behavior, clients should make sure to update visible state at an explicit "flush" event, not just the end of a "redraw" batch of event. * Get rid of copy_object() blizzard in the auto-generated ui_event layer * Special case "grid_line" by encoding screen state directly to msgpack events with no intermediate API events. * Get rid of the arcane notion of referring to the screen as the "shell" * Array and Dictionary are kvec_t:s, so define them as such. * Allow kvec_t:s, such as Arrays and Dictionaries, to be allocated with a predetermined size within an arena. * Eliminate redundant capacity checking when filling such kvec_t:s with values.
2022-06-14perf(memory): use an arena for RPC decodingbfredl1
drawback: tracing memory errors with ASAN is less accurate for arena allocated memory. Therefore, to start with it is being used for Object types around serialization/deserialization exclusively. This is going to have a large impact especially when TUI is refactored as a co-prosess as all UI events will be serialized and deserialized by nvim itself.
2021-10-12refactor: format all C files under nvim/ #15977dundargoc1
* refactor: format all C files under nvim * refactor: disable formatting for Vim-owned files: * src/nvim/indent_c.c * src/nvim/regexp.c * src/nvim/regexp_nfa.c * src/nvim/testdir/samples/memfile_test.c
2019-05-25refactor: introduce XFREE_CLEAR()Justin M. Keyes1
Unfortunately we cannot indiscriminately replace xfree() with XFREE_CLEAR(), because comparing pointers after freeing them is a common pattern. Example in `tv_list_remove_items()`: xfree(li); if (li == item2) { break; } Instead we can do it selectively/explicitly. ref #1375
2017-01-07unittest,memory: Fix testsZyX1
2017-01-07memory: Document new additions to memory.hZyX1
2017-01-07memory: Restore entered_free_all_mem functionalityZyX1
2017-01-07unittest: Allow mocking allocator callsZyX1
2016-09-13refactor: eliminate misc2.cJustin M. Keyes1
move `call_shell` to misc1.c Move some fns to state.c Move some fns to option.c Move some fns to memline.c Move `vim_chdir*` fns to file_search.c Move some fns to new module, bytes.c Move some fns to fileio.c
2015-07-01rbuffer: Reimplement as a ring buffer and decouple from rstreamThiago de Arruda1
Extract the RBuffer class from rstream.c and reimplement it as a ring buffer, a more efficient version that doesn't need to relocate memory. The old rbuffer_read/rbuffer_write interfaces are kept for simple reading/writing, and the RBUFFER_UNTIL_{FULL,EMPTY} macros are introduced to hide wrapping logic when more control is required(such as passing the buffer pointer to a library function that writes directly to the pointer) Also add a basic infrastructure for writing helper C files that are only compiled in the unit test library, and use this to write unit tests for RBuffer which contains some macros that can't be accessed directly by luajit. Helped-by: oni-link <knil.ino@gmail.com> Reviewed-by: oni-link <knil.ino@gmail.com> Reviewed-by: Scott Prager <splinterofchaos@gmail.com> Reviewed-by: Justin M. Keyes <justinkz@gmail.com> Reviewed-by: Michael Reed <m.reed@mykolab.com>
2014-07-16memory.h: don't include vim.h in header filesNicolas Hillegeer1
Also include stdint.h in khash.h. It was transitively included by vim.h via memory.h before. khash.h accidentally relied on that.
2014-06-02Add automatic generation of headersZyX1
- The 'stripdecls.py' script replaces declarations in all headers by includes to generated headers. `ag '#\s*if(?!ndef NEOVIM_).*((?!#\s*endif).*\n)*#ifdef INCLUDE_GENERATED'` was used for this. - Add and integrate gendeclarations.lua into the build system to generate the required includes. - Add -Wno-unused-function - Made a bunch of old-style definitions ANSI This adds a requirement: all type and structure definitions must be present before INCLUDE_GENERATED_DECLARATIONS-protected include. Warning: mch_expandpath (path.h.generated.h) was moved manually. So far it is the only exception.
2014-06-02Move documentation from function declarations to definitionsZyX1
Uses a perl script to move it (scripts/movedocs.pl)
2014-05-26memory: add xstrlcpyNicolas Hillegeer1
Less "blow a hole in your foot" than strncpy. As also indicated by coverity. Implementation inspired by the linux kernel (very similar to OSX's Libc implementation as well).
2014-05-24Remove long_u: do_outofmem_msg().Eliseo Martínez1
Remove long_u occurrences due to do_outofmem_msg() function. Refactor size parameter from long_u into size_t.
2014-05-19Replace alloc() with xmalloc() and remove immediate OOM checksFelipe Oliveira Carvalho1
2014-05-17Removed `lalloc` prototype(again)Thiago de Arruda1
It was re-added by accident when resolving merge conflicts
2014-05-17Fix `xmemdup` function signatureThiago de Arruda1
2014-05-15Introduce nvim namespace: Fix define guards.Eliseo Martínez1
Change define guards from NEOVIM_XXX_H to NVIM_XXX_H: - Change header files. - Change clint correct guard name calculation.
2014-05-15Introduce nvim namespace: Fix project-local includes.Eliseo Martínez1
Prepend 'nvim/' in all project-local (non-system) includes.
2014-05-15Introduce nvim namespace: Move files.Eliseo Martínez1
Move files from src/ to src/nvim/. - src/nvim/ becomes the new root dir for nvim executable sources. - src/libnvim/ is planned to become root dir of the neovim library.