refactor(options): memory management

Problem:
Numerous callers have to manually check optval ownership (i.e. whether,
and how, to release) via `is_callback_option`, `option_is_global_local`,
etc. This is fragile, hard to use correctly; and if we introduce another
optval variant in the future, we'll have to redo all of these careful
checks and boilerplate again.

Solution:
Provide a unified system and use it everywhere:

    optval_free_owned
    optval_is_owned
    optval_own
This commit is contained in:
Justin M. Keyes
2026-07-30 21:49:32 +02:00
parent 726d1a92d2
commit 3e01dcddbe
11 changed files with 208 additions and 100 deletions

View File

@@ -7741,7 +7741,7 @@ local options = {
localoptions options and mappings local to a window or buffer (not
global values for local options)
options all options and mappings (also global values for local
options)
options), except Lua functions |option-value-function|.
skiprtp exclude 'runtimepath' and 'packpath' from the options
resize size of the Vim window: 'lines' and 'columns'
sesdir the directory in which the session file is located
@@ -10419,7 +10419,8 @@ local options = {
folds manually created folds, opened/closed folds and local
fold options
options options and mappings local to a window or buffer (not
global values for local options)
global values for local options), except Lua functions
|option-value-function|.
localoptions same as "options"
slash |deprecated| Always enabled. Uses "/" in filenames.
unix |deprecated| Always enabled. Uses "\n" line endings.