From: Bert Vermeulen Date: Mon, 25 Mar 2013 19:23:13 +0000 (+0100) Subject: Add sr_config_free() X-Git-Tag: dsupstream~216 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=722db131a45dbc84aaa27cf65467a11552a32548;p=libsigrok.git Add sr_config_free() Due to struct sr_config now containing a GVariant, this needs to be cleaned up after use properly. This is a helper function for that. --- diff --git a/hwdriver.c b/hwdriver.c index 4635f3c4..40995fe7 100644 --- a/hwdriver.c +++ b/hwdriver.c @@ -368,6 +368,19 @@ SR_PRIV struct sr_config *sr_config_new(int key, GVariant *data) return src; } +SR_PRIV void sr_config_free(struct sr_config *src) +{ + + if (!src || !src->data) { + sr_err("%s: invalid data!", __func__); + return; + } + + g_variant_unref(src->data); + g_free(src); + +} + /** * Returns information about the given driver or device instance. * diff --git a/libsigrok-internal.h b/libsigrok-internal.h index 649a0a31..b8b2adc0 100644 --- a/libsigrok-internal.h +++ b/libsigrok-internal.h @@ -114,6 +114,7 @@ SR_PRIV void sr_serial_dev_inst_free(struct sr_serial_dev_inst *serial); SR_PRIV void sr_hw_cleanup_all(void); SR_PRIV struct sr_config *sr_config_new(int key, GVariant *data); +SR_PRIV void sr_config_free(struct sr_config *src); SR_PRIV int sr_source_remove(int fd); SR_PRIV int sr_source_add(int fd, int events, int timeout, sr_receive_data_callback_t cb, void *cb_data);