aboutsummaryrefslogtreecommitdiff
path: root/src/ini.c
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@users.noreply.github.com>2024-10-09 13:33:45 -0400
committerGitHub <noreply@github.com>2024-10-09 13:33:45 -0400
commit781f9873f20c45155e0dc3548bf47c74ab4a08fb (patch)
tree73d64f2b28a8742b2471b8549a81b1847f261edf /src/ini.c
parent67dc983f124dd16c2e127fc5c9e4854e7bca9078 (diff)
parent8362f2c6150ec6e41a985764639d3d910e0da08c (diff)
downloadstasis-781f9873f20c45155e0dc3548bf47c74ab4a08fb.tar.gz
Merge pull request #59 from jhunkeler/leaks-and-squeaks
Leaks and squeaks
Diffstat (limited to 'src/ini.c')
-rw-r--r--src/ini.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/ini.c b/src/ini.c
index e98b409..d44e1cc 100644
--- a/src/ini.c
+++ b/src/ini.c
@@ -319,10 +319,10 @@ int ini_data_append(struct INIFILE **ini, char *section_name, char *key, char *v
}
struct INIData **tmp = realloc(section->data, (section->data_count + 1) * sizeof(**section->data));
- if (tmp != section->data) {
- section->data = tmp;
- } else if (!tmp) {
+ if (tmp == NULL) {
return 1;
+ } else {
+ section->data = tmp;
}
if (!ini_data_get((*ini), section_name, key)) {
struct INIData **data = section->data;
@@ -350,11 +350,11 @@ int ini_data_append(struct INIFILE **ini, char *section_name, char *key, char *v
size_t value_len_new = value_len_old + value_len;
char *value_tmp = NULL;
value_tmp = realloc(data->value, value_len_new + 2);
- if (value_tmp != data->value) {
- data->value = value_tmp;
- } else if (!value_tmp) {
+ if (!value_tmp) {
SYSERROR("Unable to increase data->value size to %zu bytes", value_len_new + 2);
return -1;
+ } else {
+ data->value = value_tmp;
}
strcat(data->value, value);
}
@@ -393,9 +393,9 @@ int ini_setval(struct INIFILE **ini, unsigned type, char *section_name, char *ke
int ini_section_create(struct INIFILE **ini, char *key) {
struct INISection **tmp = realloc((*ini)->section, ((*ini)->section_count + 1) * sizeof(**(*ini)->section));
- if (!tmp) {
+ if (tmp == NULL) {
return 1;
- } else if (tmp != (*ini)->section) {
+ } else {
(*ini)->section = tmp;
}