python: initialize specific fields of PyTypeObject

Fields not named here will be zero-initialized anyway, but using this
way will be much easier to support both Python2 and Python3.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
This commit is contained in:
Marek Marczykowski-Górecki authored and Wei Liu committed 2017-02-23 13:11:12 +00:00
1 parent 7b1e5f7079
commit 0c8981f035
2 files changed
+18 -76

No files matched your search

+9 -38
View File
@@ -2675,44 +2675,15 @@ static void PyXc_dealloc(XcObject *self)
static PyTypeObject PyXcType = {
PyObject_HEAD_INIT(NULL)
0,
PKG "." CLS,
sizeof(XcObject),
0,
(destructor)PyXc_dealloc, /* tp_dealloc */
NULL, /* tp_print */
NULL, /* tp_getattr */
NULL, /* tp_setattr */
NULL, /* tp_compare */
NULL, /* tp_repr */
NULL, /* tp_as_number */
NULL, /* tp_as_sequence */
NULL, /* tp_as_mapping */
NULL, /* tp_hash */
NULL, /* tp_call */
NULL, /* tp_str */
NULL, /* tp_getattro */
NULL, /* tp_setattro */
NULL, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"Xen client connections", /* tp_doc */
NULL, /* tp_traverse */
NULL, /* tp_clear */
NULL, /* tp_richcompare */
0, /* tp_weaklistoffset */
NULL, /* tp_iter */
NULL, /* tp_iternext */
pyxc_methods, /* tp_methods */
NULL, /* tp_members */
NULL, /* tp_getset */
NULL, /* tp_base */
NULL, /* tp_dict */
NULL, /* tp_descr_get */
NULL, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)PyXc_init, /* tp_init */
NULL, /* tp_alloc */
PyXc_new, /* tp_new */
.tp_name = PKG "." CLS,
.tp_basicsize = sizeof(XcObject),
.tp_itemsize = 0,
.tp_dealloc = (destructor)PyXc_dealloc,
.tp_flags = Py_TPFLAGS_DEFAULT,
.tp_doc = "Xen client connections",
.tp_methods = pyxc_methods,
.tp_init = (initproc)PyXc_init,
.tp_new = PyXc_new,
};
static PyMethodDef xc_methods[] = { { NULL } };
+9 -38
View File
@@ -927,44 +927,15 @@ static void xshandle_dealloc(XsHandle *self)
static PyTypeObject xshandle_type = {
PyObject_HEAD_INIT(NULL)
0,
PKG "." CLS,
sizeof(XsHandle),
0,
(destructor)xshandle_dealloc, /* tp_dealloc */
NULL, /* tp_print */
NULL, /* tp_getattr */
NULL, /* tp_setattr */
NULL, /* tp_compare */
NULL, /* tp_repr */
NULL, /* tp_as_number */
NULL, /* tp_as_sequence */
NULL, /* tp_as_mapping */
NULL, /* tp_hash */
NULL, /* tp_call */
NULL, /* tp_str */
NULL, /* tp_getattro */
NULL, /* tp_setattro */
NULL, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"Xenstore connections", /* tp_doc */
NULL, /* tp_traverse */
NULL, /* tp_clear */
NULL, /* tp_richcompare */
0, /* tp_weaklistoffset */
NULL, /* tp_iter */
NULL, /* tp_iternext */
xshandle_methods, /* tp_methods */
NULL, /* tp_members */
NULL, /* tp_getset */
NULL, /* tp_base */
NULL, /* tp_dict */
NULL, /* tp_descr_get */
NULL, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)xshandle_init, /* tp_init */
NULL, /* tp_alloc */
xshandle_new, /* tp_new */
.tp_name = PKG "." CLS,
.tp_basicsize = sizeof(XsHandle),
.tp_itemsize = 0,
.tp_dealloc = (destructor)xshandle_dealloc,
.tp_flags = Py_TPFLAGS_DEFAULT,
.tp_doc = "Xenstore connections",
.tp_methods = xshandle_methods,
.tp_init = (initproc)xshandle_init,
.tp_new = xshandle_new,
};
static PyMethodDef xs_methods[] = { { NULL } };
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.