summaryrefslogtreecommitdiffstats
path: root/pywrap
diff options
context:
space:
mode:
authorVasilii Chernov <vchernov@inr.ru>2016-02-12 18:12:08 +0100
committerVasilii Chernov <vchernov@inr.ru>2016-02-12 18:12:08 +0100
commita4f3ac0b00694287e791cd7d753b420976d9f22a (patch)
treef894af8b4d2719c839d7ce238420465358cc3745 /pywrap
parent1b3342649294c6ce99aeb82664a29eac47687ee5 (diff)
downloadpcitool-a4f3ac0b00694287e791cd7d753b420976d9f22a.tar.gz
pcitool-a4f3ac0b00694287e791cd7d753b420976d9f22a.tar.bz2
pcitool-a4f3ac0b00694287e791cd7d753b420976d9f22a.tar.xz
pcitool-a4f3ac0b00694287e791cd7d753b420976d9f22a.zip
Add destructor for returning PyCObject in create_pcilib_instance function
Diffstat (limited to 'pywrap')
-rw-r--r--pywrap/pcipywrap.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/pywrap/pcipywrap.c b/pywrap/pcipywrap.c
index 8ef1dc0..a33566a 100644
--- a/pywrap/pcipywrap.c
+++ b/pywrap/pcipywrap.c
@@ -79,7 +79,6 @@ void pcilib_print_error_to_py(void *arg, const char *file, int line,
{
//copy received message to log
char* buf = full_log;
- char* buf_start = buf;
full_log = make_str("%s%s", buf, buf_wrapped_message);
free(buf);
}
@@ -105,6 +104,16 @@ void __redirect_logs_to_exeption()
}
/*!
+ * Destructor for pcilib_t
+ */
+void close_pcilib_instance(void *ctx)
+{
+ if(ctx == __ctx)
+ __ctx = NULL;
+ pcilib_close(ctx);
+}
+
+/*!
* \brief Wraps for pcilib_open function.
* \param[in] fpga_device path to the device file [/dev/fpga0]
* \param[in] model specifies the model of hardware, autodetected if NULL is passed
@@ -120,7 +129,7 @@ PyObject* create_pcilib_instance(const char *fpga_device, const char *model)
return NULL;
}
- return PyCObject_FromVoidPtr((void*)ctx, NULL);
+ return PyCObject_FromVoidPtr((void*)ctx, close_pcilib_instance);
}
/*!