From: Bert Vermeulen Date: Sun, 20 Jan 2013 15:34:38 +0000 (+0100) Subject: Add small helper for creating struct sr_config X-Git-Tag: dsupstream~333 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=4c0e310ca305ba776aa70d8062f467ac246c910b;p=libsigrok.git Add small helper for creating struct sr_config --- diff --git a/hwdriver.c b/hwdriver.c index 2c640ade..65a6fea4 100644 --- a/hwdriver.c +++ b/hwdriver.c @@ -285,6 +285,18 @@ SR_PRIV void sr_hw_cleanup_all(void) } } +SR_PRIV struct sr_config *sr_config_make(int key, const void *value) +{ + struct sr_config *src; + + if (!(src = g_try_malloc(sizeof(struct sr_config)))) + return NULL; + src->key = key; + src->value = value; + + return src; +} + /** * Returns information about the given driver or device instance. * diff --git a/libsigrok-internal.h b/libsigrok-internal.h index ea77b908..59709e63 100644 --- a/libsigrok-internal.h +++ b/libsigrok-internal.h @@ -113,6 +113,7 @@ SR_PRIV void sr_serial_dev_inst_free(struct sr_serial_dev_inst *serial); /*--- hwdriver.c ------------------------------------------------------------*/ SR_PRIV void sr_hw_cleanup_all(void); +SR_PRIV struct sr_config *sr_config_make(int key, const void *value); 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);