0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 8.2.0559: clearing a struct is verbose

Problem:    Clearing a struct is verbose.
Solution:   Define and use CLEAR_FIELD() and CLEAR_POINTER().
This commit is contained in:
Bram Moolenaar
2020-04-12 19:37:17 +02:00
parent 82de464f76
commit a80faa8930
55 changed files with 170 additions and 169 deletions

View File

@@ -3200,7 +3200,7 @@ FunctionCall(FunctionObject *self, PyObject *argsObject, PyObject *kwargs)
if (self->argv || self->self)
{
vim_memset(&pt, 0, sizeof(partial_T));
CLEAR_FIELD(pt);
set_partial(self, &pt, FALSE);
pt_ptr = &pt;
}
@@ -6420,7 +6420,7 @@ static PyTypeObject CurrentType;
static void
init_structs(void)
{
vim_memset(&OutputType, 0, sizeof(OutputType));
CLEAR_FIELD(OutputType);
OutputType.tp_name = "vim.message";
OutputType.tp_basicsize = sizeof(OutputObject);
OutputType.tp_flags = Py_TPFLAGS_DEFAULT;
@@ -6440,7 +6440,7 @@ init_structs(void)
// OutputType.tp_base = &PyFile_Type;
#endif
vim_memset(&IterType, 0, sizeof(IterType));
CLEAR_FIELD(IterType);
IterType.tp_name = "vim.iter";
IterType.tp_basicsize = sizeof(IterObject);
IterType.tp_flags = Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_GC;
@@ -6451,7 +6451,7 @@ init_structs(void)
IterType.tp_traverse = (traverseproc)IterTraverse;
IterType.tp_clear = (inquiry)IterClear;
vim_memset(&BufferType, 0, sizeof(BufferType));
CLEAR_FIELD(BufferType);
BufferType.tp_name = "vim.buffer";
BufferType.tp_basicsize = sizeof(BufferType);
BufferType.tp_dealloc = (destructor)BufferDestructor;
@@ -6472,7 +6472,7 @@ init_structs(void)
BufferType.tp_setattr = (setattrfunc)BufferSetattr;
#endif
vim_memset(&WindowType, 0, sizeof(WindowType));
CLEAR_FIELD(WindowType);
WindowType.tp_name = "vim.window";
WindowType.tp_basicsize = sizeof(WindowObject);
WindowType.tp_dealloc = (destructor)WindowDestructor;
@@ -6493,7 +6493,7 @@ init_structs(void)
WindowType.tp_setattr = (setattrfunc)WindowSetattr;
#endif
vim_memset(&TabPageType, 0, sizeof(TabPageType));
CLEAR_FIELD(TabPageType);
TabPageType.tp_name = "vim.tabpage";
TabPageType.tp_basicsize = sizeof(TabPageObject);
TabPageType.tp_dealloc = (destructor)TabPageDestructor;
@@ -6510,7 +6510,7 @@ init_structs(void)
TabPageType.tp_getattr = (getattrfunc)TabPageGetattr;
#endif
vim_memset(&BufMapType, 0, sizeof(BufMapType));
CLEAR_FIELD(BufMapType);
BufMapType.tp_name = "vim.bufferlist";
BufMapType.tp_basicsize = sizeof(BufMapObject);
BufMapType.tp_as_mapping = &BufMapAsMapping;
@@ -6518,7 +6518,7 @@ init_structs(void)
BufMapType.tp_iter = BufMapIter;
BufferType.tp_doc = "vim buffer list";
vim_memset(&WinListType, 0, sizeof(WinListType));
CLEAR_FIELD(WinListType);
WinListType.tp_name = "vim.windowlist";
WinListType.tp_basicsize = sizeof(WinListType);
WinListType.tp_as_sequence = &WinListAsSeq;
@@ -6526,14 +6526,14 @@ init_structs(void)
WinListType.tp_doc = "vim window list";
WinListType.tp_dealloc = (destructor)WinListDestructor;
vim_memset(&TabListType, 0, sizeof(TabListType));
CLEAR_FIELD(TabListType);
TabListType.tp_name = "vim.tabpagelist";
TabListType.tp_basicsize = sizeof(TabListType);
TabListType.tp_as_sequence = &TabListAsSeq;
TabListType.tp_flags = Py_TPFLAGS_DEFAULT;
TabListType.tp_doc = "vim tab page list";
vim_memset(&RangeType, 0, sizeof(RangeType));
CLEAR_FIELD(RangeType);
RangeType.tp_name = "vim.range";
RangeType.tp_basicsize = sizeof(RangeObject);
RangeType.tp_dealloc = (destructor)RangeDestructor;
@@ -6554,7 +6554,7 @@ init_structs(void)
RangeType.tp_getattr = (getattrfunc)RangeGetattr;
#endif
vim_memset(&CurrentType, 0, sizeof(CurrentType));
CLEAR_FIELD(CurrentType);
CurrentType.tp_name = "vim.currentdata";
CurrentType.tp_basicsize = sizeof(CurrentObject);
CurrentType.tp_flags = Py_TPFLAGS_DEFAULT;
@@ -6568,7 +6568,7 @@ init_structs(void)
CurrentType.tp_setattr = (setattrfunc)CurrentSetattr;
#endif
vim_memset(&DictionaryType, 0, sizeof(DictionaryType));
CLEAR_FIELD(DictionaryType);
DictionaryType.tp_name = "vim.dictionary";
DictionaryType.tp_basicsize = sizeof(DictionaryObject);
DictionaryType.tp_dealloc = (destructor)DictionaryDestructor;
@@ -6588,7 +6588,7 @@ init_structs(void)
DictionaryType.tp_setattr = (setattrfunc)DictionarySetattr;
#endif
vim_memset(&ListType, 0, sizeof(ListType));
CLEAR_FIELD(ListType);
ListType.tp_name = "vim.list";
ListType.tp_dealloc = (destructor)ListDestructor;
ListType.tp_basicsize = sizeof(ListObject);
@@ -6608,7 +6608,7 @@ init_structs(void)
ListType.tp_setattr = (setattrfunc)ListSetattr;
#endif
vim_memset(&FunctionType, 0, sizeof(FunctionType));
CLEAR_FIELD(FunctionType);
FunctionType.tp_name = "vim.function";
FunctionType.tp_basicsize = sizeof(FunctionObject);
FunctionType.tp_dealloc = (destructor)FunctionDestructor;
@@ -6625,7 +6625,7 @@ init_structs(void)
FunctionType.tp_getattr = (getattrfunc)FunctionGetattr;
#endif
vim_memset(&OptionsType, 0, sizeof(OptionsType));
CLEAR_FIELD(OptionsType);
OptionsType.tp_name = "vim.options";
OptionsType.tp_basicsize = sizeof(OptionsObject);
OptionsType.tp_as_sequence = &OptionsAsSeq;
@@ -6638,7 +6638,7 @@ init_structs(void)
OptionsType.tp_clear = (inquiry)OptionsClear;
#if PY_VERSION_HEX < 0x030700f0
vim_memset(&LoaderType, 0, sizeof(LoaderType));
CLEAR_FIELD(LoaderType);
LoaderType.tp_name = "vim.Loader";
LoaderType.tp_basicsize = sizeof(LoaderObject);
LoaderType.tp_flags = Py_TPFLAGS_DEFAULT;
@@ -6648,7 +6648,7 @@ init_structs(void)
#endif
#if PY_MAJOR_VERSION >= 3
vim_memset(&vimmodule, 0, sizeof(vimmodule));
CLEAR_FIELD(vimmodule);
vimmodule.m_name = "vim";
vimmodule.m_doc = "Vim Python interface\n";
vimmodule.m_size = -1;