Mercurial > hg > th-libs
changeset 518:4913e4230e5c
Cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 26 Dec 2019 13:05:40 +0200 |
parents | 80185b9901ba |
children | e1b15fb56ddf |
files | th_config.c |
diffstat | 1 files changed, 9 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/th_config.c Thu Dec 26 13:03:03 2019 +0200 +++ b/th_config.c Thu Dec 26 13:05:40 2019 +0200 @@ -46,8 +46,7 @@ return NULL; // Allocate new item - node = (th_cfgitem_t *) th_malloc0(sizeof(th_cfgitem_t)); - if (node == NULL) + if ((node = (th_cfgitem_t *) th_malloc0(sizeof(th_cfgitem_t))) == NULL) return NULL; // Set values @@ -66,9 +65,7 @@ */ int th_cfg_add_int(th_cfgitem_t **cfg, const char *name, int *itemData, int defValue) { - th_cfgitem_t *node; - - node = th_cfg_add(cfg, name, ITEM_INT, (void *) itemData); + th_cfgitem_t *node = th_cfg_add(cfg, name, ITEM_INT, (void *) itemData); if (node == NULL) return THERR_MALLOC; @@ -81,9 +78,7 @@ int th_cfg_add_hexvalue(th_cfgitem_t **cfg, const char *name, unsigned int *itemData, unsigned int defValue) { - th_cfgitem_t *node; - - node = th_cfg_add(cfg, name, ITEM_HEX_TRIPLET, (void *) itemData); + th_cfgitem_t *node = th_cfg_add(cfg, name, ITEM_HEX_TRIPLET, (void *) itemData); if (node == NULL) return THERR_MALLOC; @@ -98,9 +93,7 @@ int th_cfg_add_uint(th_cfgitem_t **cfg, const char *name, unsigned int *itemData, unsigned int defValue) { - th_cfgitem_t *node; - - node = th_cfg_add(cfg, name, ITEM_UINT, (void *) itemData); + th_cfgitem_t *node = th_cfg_add(cfg, name, ITEM_UINT, (void *) itemData); if (node == NULL) return THERR_MALLOC; @@ -115,9 +108,7 @@ int th_cfg_add_string(th_cfgitem_t **cfg, const char *name, char **itemData, char *defValue) { - th_cfgitem_t *node; - - node = th_cfg_add(cfg, name, ITEM_STRING, (void *) itemData); + th_cfgitem_t *node = th_cfg_add(cfg, name, ITEM_STRING, (void *) itemData); if (node == NULL) return THERR_MALLOC; @@ -132,9 +123,7 @@ int th_cfg_add_bool(th_cfgitem_t **cfg, const char *name, BOOL *itemData, BOOL defValue) { - th_cfgitem_t *node; - - node = th_cfg_add(cfg, name, ITEM_BOOL, (void *) itemData); + th_cfgitem_t *node = th_cfg_add(cfg, name, ITEM_BOOL, (void *) itemData); if (node == NULL) return THERR_MALLOC; @@ -148,9 +137,7 @@ */ int th_cfg_add_comment(th_cfgitem_t **cfg, const char *comment) { - th_cfgitem_t *node; - - node = th_cfg_add(cfg, comment, ITEM_COMMENT, NULL); + th_cfgitem_t *node = th_cfg_add(cfg, comment, ITEM_COMMENT, NULL); if (node == NULL) return THERR_MALLOC; @@ -162,9 +149,7 @@ */ int th_cfg_add_section(th_cfgitem_t **cfg, const char *name, th_cfgitem_t *sect) { - th_cfgitem_t *node; - - node = th_cfg_add(cfg, name, ITEM_SECTION, (void *) sect); + th_cfgitem_t *node = th_cfg_add(cfg, name, ITEM_SECTION, (void *) sect); if (node == NULL) return THERR_MALLOC; @@ -179,8 +164,7 @@ if (data == NULL) return THERR_NULLPTR; - node = th_cfg_add(cfg, name, ITEM_STRING_LIST, (void *) data); - if (node == NULL) + if ((node = th_cfg_add(cfg, name, ITEM_STRING_LIST, (void *) data)) == NULL) return THERR_MALLOC; return THERR_OK;