aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/memory.c
Commit message (Collapse)AuthorAge
...
* api: nvim_get_mode()Justin M. Keyes2017-04-28
| | | | | | | | | | | | | | | | | | | | | | | | | | Asynchronous API functions are served immediately, which means pending input could change the state of Nvim shortly after an async API function result is returned. nvim_get_mode() is different: - If RPCs are known to be blocked, it responds immediately (without flushing the input/event queue) - else it is handled just-in-time before waiting for input, after pending input was processed. This makes the result more reliable (but not perfect). Internally this is handled as a special case, but _semantically_ nothing has changed: API users never know when input flushes, so this internal special-case doesn't violate that. As far as API users are concerned, nvim_get_mode() is just another asynchronous API function. In all cases nvim_get_mode() never blocks for more than the time it takes to flush the input/event queue (~µs). Note: This doesn't address #6166; nvim_get_mode() will provoke #6166 if e.g. `d` is operator-pending. Closes #6159
* *: Add comment to all C filesZyX2017-04-19
|
* win: os_shell_is_cmdexe() + testsJustin M. Keyes2017-04-12
|
* eval: Split eval.c into smaller filesZyX2017-03-29
|
* DirChanged: trigger when switching scopesJustin M. Keyes2017-03-12
| | | | Closes #6054
* *: Fix linter errorsZyX2017-02-25
|
* memory: Free buffers after freeing variablesZyX2017-02-24
| | | Avoids use-after-free crashes when compiling with -DEXITFREE.
* vim-patch:7.4.2024Marco Hinz2017-02-04
| | | | | | | | | | Problem: More buf_valid() calls can be optimized. Solution: Use bufref_valid() instead. NOTE: Some changes related to channels and the Python and Netbeans interfaces were obviously left out. https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
* xstrlcat: Allow overlapped pointers. (#6017)Justin M. Keyes2017-01-31
| | | | | | | | | | memcpy is not equivalent to memmove (which is used by vim_strcat), this could cause subtle bugs if xstrlcat is used as a replacement for vim_strcat. But vim_strcat is inconsistent: in the `else` branch it uses strcpy, which doesn't allow overlap. Helped-by: oni-link <knil.ino@gmail.com> Helped-by: James McCoy <jamessan@jamessan.com> Helped-by: Nikolai Aleksandrovich Pavlov <kp-pav@yandex.ru>
* refactor: Remove strncpy/STRNCPY. (#6008)Justin M. Keyes2017-01-26
| | | | | | | | | | | | | | | Closes #731 References #851 Note: This does not remove some intentional legacy usages of strncpy. - memcpy isn't equivalent because it doesn't check the string length of `src`, and doesn't zero-out the remainder of `dst`. - xstrlcpy isn't equivalent because it doesn't zero-out the remainder of `dst`. Some Vim logic depends on that (e.g. ex_append which calls vim_strnsave). Helped-by: Douglas Schneider <ds3@ualberta.ca> Helped-by: oni-link <knil.ino@gmail.com> Helped-by: James McCoy <jamessan@jamessan.com>
* refactor: strlcat instead of str{n}cat.cztchoice2017-01-23
| | | | | | | | | | Add xstrlcat function. Closes #3042 References #988 References #1069 coverity: 71530, 71531, 71532
* memory: Document new additions to memory.hZyX2017-01-07
|
* memory: Restore entered_free_all_mem functionalityZyX2017-01-07
|
* unittest: Allow mocking allocator callsZyX2017-01-07
|
* lintJames McCoy2017-01-02
|
* vim-patch:7.4.1868James McCoy2017-01-01
| | | | | | | Problem: Setting really_exiting causes memory leaks to be reported. Solution: Add the in_free_all_mem flag. https://github.com/vim/vim/commit/b89a25f17e274dc308c584ea69a129ffbb26bc3d
* vim-patch:7.4.1866James McCoy2017-01-01
| | | | | | | | | | | | Problem: Invalid memory access when exiting with EXITFREE defined. (Dominique Pelle) Solution: Set "really_exiting" and skip error messages. https://github.com/vim/vim/commit/a96732150cda2f242133228579b05437a39b8daa This fails to build, due to a00c2e0ecbaec366364cecb5efbdb456c8c543ef removing really_exiting from globals.h, but the next commit fixes the build failure.
* os/shell: do_os_system(): Always show last chunk.Justin M. Keyes2016-12-10
| | | | | | | | | | | | | | | | | | | | | This ameliorates use-cases like: :!cat foo.txt :make where the user is interested in the last few lines of output. Try these shell-based ex-commands before/after this commit: :grep -r '' * :make :!yes :!grep -r '' * :!git grep '' :!cat foo :!echo foo :!while true; do date; done :!for i in `seq 1 20000`; do echo XXXXXXXXXX $i; done In all cases the last few lines of the command should always be shown, regardless of where throttling was triggered.
* refactor: eliminate misc2.cJustin M. Keyes2016-09-13
| | | | | | | | | | 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
* Remove unnecessary includes for errno.hRui Abreu Ferreira2015-11-25
|
* memory.c: Prevent garbage collection when running out of memory.oni-link2015-11-13
| | | | | | | | | | When running out of memory, garbage collection would free lists and dictionaries that are not yet referenced. This would later on lead to a use-after-free for these objects. Releated to vim-patch:7.4.916, so also updating version.c. Patch by @ZyX-I
* shada: Refactor file reading/writing to use os_openZyX2015-10-08
|
* Remove instances of TRUE/FALSE macroSteven Oliver2015-09-04
| | | | | | memory.c os_unix.c path.c
* Remove char_u: ex_docmd:do_cmdline_cmd()Michael Reed2015-05-13
|
* jemalloc: Force use of prefixed functions.Florian Walch2015-04-29
| | | | | | | | * Set JEMALLOC_NO_DEMANGLE to be able to use `je_*` functions, regardless of how jemalloc was compiled (--with-jemalloc-prefix) * Show jemalloc information in Neovim's version output. Resolve #2449.
* deps: Add jemalloc as an optional dependencyThiago de Arruda2015-04-13
| | | | | | | | | | | | Jemalloc will be used if the cmake option `USE_JEMALLOC` is enabled(which is the default). To avoid trouble with clang's ASAN, it is disabled by default if the `SANITIZE` option is enabled. Since jemalloc has thread cache for small objects, it fills the gap created by removing klib memory pools. The `xstrdup` funciton(memory.c) had to be reimplemented on top of `xmalloc` to make it work with a custom allocator.
* memory: Add `free` wrapper and refactor project to use itThiago de Arruda2015-04-13
| | | | | | We already use wrappers for allocation, the new `xfree` function is the equivalent for deallocation and provides a way to fully replace the malloc implementation used by Neovim.
* misc2.c: Move emsg* functions to message.c #2152Michael Reed2015-03-19
| | | | Clean up said functions and some outdated comments while we're at it.
* refactor: Remove term modules and termcap optionsThiago de Arruda2015-02-21
| | | | | | | | | | | | | | | - Removed term.c, term.h and term_defs.h - Tests for T_* values were removed. screen.c was simplified as a consequence(the best strategy for drawing is implemented in the UI layer) - Redraw functions now call ui.c functions directly. Updates are flushed with `ui_flush()` - Removed all termcap options(they now return empty strings for compatibility) - &term/&ttybuiltin options return a constant value(nvim) - &t_Co is still available, but it mirrors t_colors directly - Remove cursor tracking from screen.c and the `screen_start` function. Now the UI is expected to maintain cursor state across any call, and reset it when resized. - Remove unused code
* vim-patch:7.4.446Pavel Platto2015-01-20
| | | | | | | | | Problem: In some situations, when setting up an environment to trigger an autocommand, the environment is not properly restored. Solution: Check the return value of switch_win() and call restore_win() always. (Daniel Hahler) https://code.google.com/p/vim/source/detail?r=v7-4-446
* Macro cleanup: PROTOMichael Reed2015-01-14
| | | | | | Regarding dict_lookup() in eval.c: both definitions are the same, the only difference being the spacing between the indirection operator and the indentation level.
* strcnt: remove unused parameterJustin M. Keyes2014-12-12
|
* memory: memcnt and strcnt.Scott Prager2014-12-11
|
* Merge pull request #1497 from splinterofchaos/const-attrJustin M. Keyes2014-11-29
|\ | | | | constify and func-attribute memory.c and strings.c
| * strings/memory: constify and func_attr.Scott Prager2014-11-27
| | | | | | | | Fix MB_COPY_cHAR() to accept const pointers.
* | ui: Remove redundant ui.h includesThiago de Arruda2014-11-27
|/ | | | Also move read_error_exit to os/input.c
* Fix substitute newline: Memory functions: Improve style.Eliseo Martínez2014-11-24
| | | | | | | | `try_malloc` was changed in 8bb2c2c0742c57150655e18cf8418a758cebdce8 to avoid a warning when size is 0. Then, this improves some things on that: - Use local vars instead of changing parameters. - Homogenize style for other related functions.
* Merge pull request #1439 from jszakmeister/shuffle-some-includesJustin M. Keyes2014-11-11
|\ | | | | Move many includes down to the EXITFREE block.
| * Move many includes down to the EXITFREE block.John Szakmeister2014-11-09
| | | | | | | | | | | | | | They're unnecessary for the rest of the file, and they're only there at all to help implement `free_all_mem` for use with Clang's Address Sanitizer. So let's move them to avoid any confusion about why they are there.
* | Fix warnings: memory.c: xcalloc(): 0 size calloc: CW.Eliseo Martínez2014-11-11
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | Problem : Undefined allocation of 0 bytes (CERT MEM04-C; CWE-131) @ 148. Diagnostic : Cautionary warning. Rationale : Reported circumstance (calling calloc with requesting 0 size allocation) can occur, and it's not an issue. It's perfectly legal doing so, though result is implementation dependant. A given implementation can return NULL or a valid pointer, so that free() can be called on it later the same as if it was a real pointer. Such a pointer should not be dereferenced, though. Now, for some reason I can't explain, compiler is warning us in the case of calloc, but not in the case of malloc, which is doing the same. Resolution : Refactor memory functions to avoid using implementation dependant behaviour. Proposed code is neater to read, and it avoids calling system memory functions with size 0, thus behaving the same everywhere. Note that semantics for xmalloc/xcalloc is slightly changed: - Previously, an implementation that returns a valid pointer on malloc/calloc with 0 size, would return that pointer to xmalloc/xcalloc caller. - Currently, a regular pointer is always returned.
* memory: implement xmemrchr()Scott Prager2014-11-07
|
* memory: memchrsub and strchrsubScott Prager2014-09-30
|
* memory: xstrchrnul and xmemscan.Scott Prager2014-09-30
|
* FOR_ALL_WINDOWS_IN_TAB and local variables in FOR_ALL_TAB_WINDOWSWayne Rowcliffe2014-09-22
|
* memory: Use i18n messages for memory-related errorsThiago de Arruda2014-09-12
|
* Statically allocate NameBuffWayne Rowcliffe2014-07-22
|
* Use strict function prototypes #945Pavel Platto2014-07-14
| | | | | | | | | | | | | | | | | | | `-Wstrict-prototypes` warn if a function is declared or defined without specifying the argument types. This warning disallow function prototypes with empty parameter list. In C, a function declared with an empty parameter list accepts an arbitrary number of arguments when being called. This is for historic reasons; originally, C functions didn't have prototypes, as C evolved from B, a typeless language. When prototypes were added, the original typeless declarations were left in the language for backwards compatibility. Instead we should provide `void` in argument list to state that function doesn't have arguments. Also this warning disallow declaring type of the parameters after the parentheses because Neovim header generator produce no declarations for old-stlyle prototypes: it expects to find `{` after prototype.
* move errno.h include out of vim.hBrandon Coleman2014-07-09
|
* move <inttypes.h> include out of vim.hBrandon Coleman2014-07-09
|
* remove stdbool.h include from vim.h and globals.hBrandon Coleman2014-07-09
|