diff options
author | Bert Vermeulen <bert@biot.com> | 2013-01-01 01:09:46 +0100 |
---|---|---|
committer | Bert Vermeulen <bert@biot.com> | 2013-01-01 01:09:46 +0100 |
commit | c78eeef14ff4c23d021adf7c439ea173a651db7e (patch) | |
tree | 975df3ba3e1c7a6be2561cb9bf1b87ea0e840560 /controller.c | |
parent | 2218c267081268865fc90ee607c4c6ced541bfed (diff) | |
download | libsigrokdecode-c78eeef14ff4c23d021adf7c439ea173a651db7e.tar.gz libsigrokdecode-c78eeef14ff4c23d021adf7c439ea173a651db7e.zip |
srd_inst_new() options can be NULL
Diffstat (limited to 'controller.c')
-rw-r--r-- | controller.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/controller.c b/controller.c index 2803c6f..c265ae7 100644 --- a/controller.c +++ b/controller.c @@ -420,7 +420,7 @@ SRD_API int srd_inst_probe_set_all(struct srd_decoder_inst *di, * * @param decoder_id Decoder 'id' field. * @param options GHashtable of options which override the defaults set in - * the decoder class. + * the decoder class. May be NULL. * * @return Pointer to a newly allocated struct srd_decoder_inst, or * NULL in case of failure. @@ -445,10 +445,13 @@ SRD_API struct srd_decoder_inst *srd_inst_new(const char *decoder_id, return NULL; } - inst_id = g_hash_table_lookup(options, "id"); di->decoder = dec; - di->inst_id = g_strdup(inst_id ? inst_id : decoder_id); - g_hash_table_remove(options, "id"); + if (options) { + inst_id = g_hash_table_lookup(options, "id"); + di->inst_id = g_strdup(inst_id ? inst_id : decoder_id); + g_hash_table_remove(options, "id"); + } else + di->inst_id = g_strdup(decoder_id); /* * Prepare a default probe map, where samples come in the @@ -477,7 +480,7 @@ SRD_API struct srd_decoder_inst *srd_inst_new(const char *decoder_id, return NULL; } - if (srd_inst_option_set(di, options) != SRD_OK) { + if (options && srd_inst_option_set(di, options) != SRD_OK) { g_free(di->dec_probemap); g_free(di); return NULL; |