summaryrefslogtreecommitdiff
path: root/python/tag.cc
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2009-07-14 23:38:17 +0200
committerJulian Andres Klode <jak@debian.org>2009-07-14 23:38:17 +0200
commit9e3bab4299962d51cabce425e8b82804008b73e6 (patch)
tree58e47e8dd379437eb7545754102fb09f66bae573 /python/tag.cc
parent8430dbf041ce70dcba81101678beee0492252fd2 (diff)
downloadpython-apt-9e3bab4299962d51cabce425e8b82804008b73e6.tar.gz
python/tag.cc: TagFileData is now subclassed from CppOwnedPyObject<pkgTagFile>.
Diffstat (limited to 'python/tag.cc')
-rw-r--r--python/tag.cc15
1 files changed, 8 insertions, 7 deletions
diff --git a/python/tag.cc b/python/tag.cc
index b393effe..24a43320 100644
--- a/python/tag.cc
+++ b/python/tag.cc
@@ -39,10 +39,9 @@ struct TagSecData : public CppOwnedPyObject<pkgTagSection>
char *Data;
};
-struct TagFileData : public PyObject
+// The owner of the TagFile is a Python file object.
+struct TagFileData : public CppOwnedPyObject<pkgTagFile>
{
- pkgTagFile Object;
- PyObject *File;
TagSecData *Section;
FileFd Fd;
};
@@ -50,11 +49,13 @@ struct TagFileData : public PyObject
// Traversal and Clean for owned objects
int TagFileTraverse(PyObject *self, visitproc visit, void* arg) {
Py_VISIT(((TagFileData *)self)->Section);
+ Py_VISIT(((TagFileData *)self)->Owner);
return 0;
}
int TagFileClear(PyObject *self) {
Py_CLEAR(((TagFileData *)self)->Section);
+ Py_CLEAR(((TagFileData *)self)->Owner);
return 0;
}
@@ -79,10 +80,10 @@ void TagFileFree(PyObject *Obj)
std::cerr << "=== DEALLOCATING " << Obj->ob_type->tp_name << "^ ===\n";
#endif
TagFileData *Self = (TagFileData *)Obj;
- TagFileClear(Obj);
+ Py_CLEAR(Self->Section);
Self->Object.~pkgTagFile();
Self->Fd.~FileFd();
- Py_DECREF(Self->File);
+ Py_CLEAR(Self->Owner);
Obj->ob_type->tp_free(Obj);
}
/*}}}*/
@@ -310,8 +311,8 @@ static PyObject *TagFileNew(PyTypeObject *type,PyObject *Args,PyObject *kwds)
TagFileData *New = (TagFileData*)type->tp_alloc(type, 0);
new (&New->Fd) FileFd(fileno,false);
- New->File = File;
- Py_INCREF(New->File);
+ New->Owner = File;
+ Py_INCREF(New->Owner);
new (&New->Object) pkgTagFile(&New->Fd);
// Create the section