diff options
author | Bert Vermeulen <bert@biot.com> | 2012-01-22 03:29:22 +0100 |
---|---|---|
committer | Bert Vermeulen <bert@biot.com> | 2012-01-23 04:53:32 +0100 |
commit | 4fadb1282f5e9aa41abcb67e7d90cdc4a9b2628d (patch) | |
tree | 2728b461f591280818ef8e2d9d0411684a7f09a3 | |
parent | d567790b9c0ab30b18aceb92e6714e631200e9b9 (diff) | |
download | libsigrokdecode-4fadb1282f5e9aa41abcb67e7d90cdc4a9b2628d.tar.gz libsigrokdecode-4fadb1282f5e9aa41abcb67e7d90cdc4a9b2628d.zip |
srd: minor code cleanup
-rw-r--r-- | controller.c | 70 | ||||
-rw-r--r-- | decoder.c | 2 | ||||
-rw-r--r-- | util.c | 2 |
3 files changed, 38 insertions, 36 deletions
diff --git a/controller.c b/controller.c index c696dd3..d205691 100644 --- a/controller.c +++ b/controller.c @@ -275,6 +275,7 @@ err_out: return ret; } +/* Helper GComparefunc for g_slist_find_custom() in srd_instance_set_probes() */ static gint compare_probe_id(struct srd_probe *a, char *probe_id) { @@ -604,6 +605,41 @@ int srd_session_feed(uint64_t start_samplenum, uint8_t *inbuf, uint64_t inbuflen } +int srd_register_callback(int output_type, void *cb) +{ + struct srd_pd_callback *pd_cb; + + srd_dbg("srd: registering new callback for output type %d", output_type); + + if (!(pd_cb = g_try_malloc(sizeof(struct srd_pd_callback)))) + return SRD_ERR_MALLOC; + + pd_cb->output_type = output_type; + pd_cb->callback = cb; + callbacks = g_slist_append(callbacks, pd_cb); + + return SRD_OK; +} + +void *srd_find_callback(int output_type) +{ + GSList *l; + struct srd_pd_callback *pd_cb; + void *(cb); + + cb = NULL; + for (l = callbacks; l; l = l->next) { + pd_cb = l->data; + if (pd_cb->output_type == output_type) { + cb = pd_cb->callback; + break; + } + } + + return cb; +} + + /* This is the backend function to python sigrokdecode.add() call. */ int pd_add(struct srd_decoder_instance *di, int output_type, char *proto_id) @@ -646,37 +682,3 @@ struct srd_decoder_instance *get_di_by_decobject(void *decobject) return NULL; } -int srd_register_callback(int output_type, void *cb) -{ - struct srd_pd_callback *pd_cb; - - srd_dbg("srd: registering new callback for output type %d", output_type); - - if (!(pd_cb = g_try_malloc(sizeof(struct srd_pd_callback)))) - return SRD_ERR_MALLOC; - - pd_cb->output_type = output_type; - pd_cb->callback = cb; - callbacks = g_slist_append(callbacks, pd_cb); - - return SRD_OK; -} - -void *srd_find_callback(int output_type) -{ - GSList *l; - struct srd_pd_callback *pd_cb; - void *(cb); - - cb = NULL; - for (l = callbacks; l; l = l->next) { - pd_cb = l->data; - if (pd_cb->output_type == output_type) { - cb = pd_cb->callback; - break; - } - } - - return cb; -} - @@ -2,7 +2,7 @@ * This file is part of the sigrok project. * * Copyright (C) 2010 Uwe Hermann <uwe@hermann-uwe.de> - * Copyright (C) 2011 Bert Vermeulen <bert@biot.com> + * Copyright (C) 2012 Bert Vermeulen <bert@biot.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -2,7 +2,7 @@ * This file is part of the sigrok project. * * Copyright (C) 2010 Uwe Hermann <uwe@hermann-uwe.de> - * Copyright (C) 2011 Bert Vermeulen <bert@biot.com> + * Copyright (C) 2012 Bert Vermeulen <bert@biot.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by |