diff options
author | Uwe Hermann <uwe@hermann-uwe.de> | 2015-03-07 19:12:15 +0100 |
---|---|---|
committer | Uwe Hermann <uwe@hermann-uwe.de> | 2015-04-01 00:25:51 +0200 |
commit | 077fa8acbcb8b585af6f5323f16221940a27a72e (patch) | |
tree | 564a091540e1d929e9e019a7f89658d1de55af2f /decoder.c | |
parent | c052046717c09758bbdf62819e0029dddcae7159 (diff) | |
download | libsigrokdecode-077fa8acbcb8b585af6f5323f16221940a27a72e.tar.gz libsigrokdecode-077fa8acbcb8b585af6f5323f16221940a27a72e.zip |
Use g_malloc*() consistently, simplify error handling.
Use g_malloc*() for small allocations and assume they always
succeed. Simplify error handling in a few places accordingly.
Document the rules in the README file.
Diffstat (limited to 'decoder.c')
-rw-r--r-- | decoder.c | 14 |
1 files changed, 3 insertions, 11 deletions
@@ -132,11 +132,7 @@ static int get_channels(const struct srd_decoder *d, const char *attr, break; } - if (!(pdch = g_try_malloc(sizeof(struct srd_channel)))) { - srd_err("Failed to g_malloc() struct srd_channel."); - ret = SRD_ERR_MALLOC; - break; - } + pdch = g_malloc(sizeof(struct srd_channel)); if ((py_dictitem_as_str(py_entry, "id", &pdch->id)) != SRD_OK) { ret = SRD_ERR_PYTHON; @@ -331,11 +327,7 @@ SRD_API int srd_decoder_load(const char *module_name) py_basedec = py_method = py_attr = NULL; - if (!(d = g_try_malloc0(sizeof(struct srd_decoder)))) { - srd_dbg("Failed to g_malloc() struct srd_decoder."); - ret = SRD_ERR_MALLOC; - goto err_out; - } + d = g_malloc0(sizeof(struct srd_decoder)); ret = SRD_ERR_PYTHON; @@ -367,7 +359,7 @@ SRD_API int srd_decoder_load(const char *module_name) Py_CLEAR(py_basedec); /* - * Check that thіs decoder has the correct PD API version. + * Check that this decoder has the correct PD API version. * PDs of different API versions are incompatible and cannot work. */ py_long = PyObject_GetAttrString(d->py_dec, "api_version"); |