Skip to content

Commit b060e41

Browse files
Move memset into a dedicated structure to initialise the python type object.
1 parent 0686a2b commit b060e41

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pythonBuffer.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,12 @@ namespace classdesc
526526
{nullptr, nullptr, 0, nullptr}
527527
};
528528

529-
struct CppWrapperType: public PyTypeObject
529+
struct InitialisedPyTypeObject: public PyTypeObject
530+
{
531+
InitialisedPyTypeObject() {memset(this,0,sizeof(PyTypeObject));}
532+
};
533+
534+
struct CppWrapperType: public InitialisedPyTypeObject
530535
{
531536
// container commands that take a key as as an argument
532537
static bool containerSpecialCommand(const std::string& command)
@@ -645,7 +650,6 @@ namespace classdesc
645650

646651
CppWrapperType()
647652
{
648-
memset(this,0,sizeof(PyTypeObject));
649653
Py_INCREF(this);
650654
tp_name="CppWrapperType";
651655
tp_methods=cppWrapperMethods;

0 commit comments

Comments
 (0)