mirror of
https://github.com/neovim/neovim.git
synced 2026-08-28 01:51:52 +00:00
Functions like file_open_new() and file_open_fd_new() which just is a wrapper around the real functions but with an extra xmalloc/xfree around is an anti-pattern. If the caller really needs to allocate a FileDescriptor as a heap object, it can do that directly. FileDescriptor by itself is pretty much a pointer, or rather two: the OS fd index and a pointer to a buffer. So most of the time an extra pointer layer is just wasteful. In the case of scriptin[curscript] in getchar.c, curscript used to mean in practice: N+1 open scripts when curscript>0 zero or one open scripts when curscript==0 Which means scriptin[0] had to be compared to NULL to disambiguate the curscript=0 case. Instead, use curscript==-1 to mean that are no script, then all pointer comparisons dissappear and we can just use an array of structs without extra pointers.
23 lines
650 B
C
23 lines
650 B
C
#pragma once
|
|
|
|
#include <stddef.h> // IWYU pragma: keep
|
|
#include <stdint.h> // IWYU pragma: keep
|
|
|
|
#include "nvim/eval/typval_defs.h" // IWYU pragma: keep
|
|
#include "nvim/getchar_defs.h" // IWYU pragma: keep
|
|
#include "nvim/os/fileio_defs.h"
|
|
#include "nvim/types_defs.h" // IWYU pragma: keep
|
|
|
|
/// Argument for flush_buffers().
|
|
typedef enum {
|
|
FLUSH_MINIMAL,
|
|
FLUSH_TYPEAHEAD, ///< flush current typebuf contents
|
|
FLUSH_INPUT, ///< flush typebuf and inchar() input
|
|
} flush_buffers_T;
|
|
|
|
enum { NSCRIPT = 15, }; ///< Maximum number of streams to read script from
|
|
|
|
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
|
# include "getchar.h.generated.h"
|
|
#endif
|