From 1040f7f6ec9cf689d6530827348a63daad52b3ef Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 8 Jun 2009 17:17:48 +0200 Subject: python/generic.h,tag.cc,configuration.cc: Use tp_alloc/tp_free instead of PyObject_NEW/DEL This allows us to finally implement subclassing. Previously deletion of an instance of a subclass caused segmentation faults, this is not the case anymore. --- python/tag.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'python/tag.cc') diff --git a/python/tag.cc b/python/tag.cc index 5a31488c..31491c90 100644 --- a/python/tag.cc +++ b/python/tag.cc @@ -68,7 +68,7 @@ void TagFileFree(PyObject *Obj) Self->Object.~pkgTagFile(); Self->Fd.~FileFd(); Py_DECREF(Self->File); - PyObject_DEL(Obj); + Obj->ob_type->tp_free(Obj); } /*}}}*/ @@ -246,7 +246,7 @@ static PyObject *TagSecNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) { return 0; // Create the object.. - TagSecData *New = PyObject_NEW(TagSecData,type); + TagSecData *New = (TagSecData*)type->tp_alloc(type, 0); new (&New->Object) pkgTagSection(); New->Data = new char[strlen(Data)+2]; snprintf(New->Data,strlen(Data)+2,"%s\n",Data); @@ -286,14 +286,14 @@ static PyObject *TagFileNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) if (fileno == -1) return 0; - TagFileData *New = PyObject_NEW(TagFileData,type); + TagFileData *New = (TagFileData*)type->tp_alloc(type, 0); new (&New->Fd) FileFd(fileno,false); New->File = File; Py_INCREF(New->File); new (&New->Object) pkgTagFile(&New->Fd); // Create the section - New->Section = PyObject_NEW(TagSecData,&TagSecType); + New->Section = (TagSecData*)(&TagSecType)->tp_alloc(&TagSecType, 0); new (&New->Section->Object) pkgTagSection(); New->Section->Data = 0; -- cgit v1.2.3