diff options
author | Karel Zak | 2013-08-22 09:44:38 +0200 |
---|---|---|
committer | Karel Zak | 2013-08-22 09:44:38 +0200 |
commit | 20b222ec5c6bd4dbfc3d88efdb4b32839629efb3 (patch) | |
tree | 4049ccbc39d8728bd9cdef0f103d854fb87f879d /libmount/python/fs.c | |
parent | misc: use libmnt_table reference counter (diff) | |
download | kernel-qcow2-util-linux-20b222ec5c6bd4dbfc3d88efdb4b32839629efb3.tar.gz kernel-qcow2-util-linux-20b222ec5c6bd4dbfc3d88efdb4b32839629efb3.tar.xz kernel-qcow2-util-linux-20b222ec5c6bd4dbfc3d88efdb4b32839629efb3.zip |
pylibmount: use libmount reference counting
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/python/fs.c')
-rw-r--r-- | libmount/python/fs.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/libmount/python/fs.c b/libmount/python/fs.c index 5868d41ce..fd8024432 100644 --- a/libmount/python/fs.c +++ b/libmount/python/fs.c @@ -573,7 +573,8 @@ static PyMethodDef Fs_methods[] = { static void Fs_dealloc(FsObject *self) { - mnt_free_fs(self->fs); + fprintf(stderr, "KZAK: [%p] delalocate\n", self->fs); + mnt_unref_fs(self->fs); self->ob_type->tp_free((PyObject*)self); } @@ -606,9 +607,10 @@ static int Fs_init(FsObject *self, PyObject *args, PyObject *kwds) return -1; } if (self->fs) - mnt_free_fs(self->fs); + mnt_unref_fs(self->fs); + + self->fs = mnt_new_fs(); /* new FS with refcount=1 */ - self->fs = mnt_new_fs(); if (source && (rc = mnt_fs_set_source(self->fs, source))) { PyErr_SetString(PyExc_MemoryError, MEMORY_ERR); return rc; @@ -713,6 +715,8 @@ PyObject *PyObjectResultFs(struct libmnt_fs *fs) } Py_INCREF(result); + mnt_ref_fs(fs); + result->fs = fs; mnt_fs_set_userdata(fs, result); return (PyObject *) result; @@ -786,7 +790,7 @@ PyTypeObject FsType = { Fs_new, /* tp_new */ }; -void pymnt_init_fs(PyObject *mod) +void FS_AddModuleObject(PyObject *mod) { if (PyType_Ready(&FsType) < 0) return; |