aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmdsserver/linked-list.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-12-08 19:15:24 +0100
committerMattias Andrée <maandree@operamail.com>2014-12-08 19:15:24 +0100
commite9880491796516b7e2f835a3df6f20e5da06ebf7 (patch)
treedc10120bd50d39aa092bea82c1143e5df845ee04 /src/libmdsserver/linked-list.c
parentreplace all variants of goto pfail with fail_if (diff)
downloadmds-e9880491796516b7e2f835a3df6f20e5da06ebf7.tar.gz
mds-e9880491796516b7e2f835a3df6f20e5da06ebf7.tar.bz2
mds-e9880491796516b7e2f835a3df6f20e5da06ebf7.tar.xz
no more goto fail
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/libmdsserver/linked-list.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/libmdsserver/linked-list.c b/src/libmdsserver/linked-list.c
index 6c8e185..83f7711 100644
--- a/src/libmdsserver/linked-list.c
+++ b/src/libmdsserver/linked-list.c
@@ -95,10 +95,10 @@ int linked_list_create(linked_list_t* restrict this, size_t capacity)
*/
void linked_list_destroy(linked_list_t* restrict this)
{
- free(this->reusable); this->reusable = NULL;
- free(this->values); this->values = NULL;
- free(this->next); this->next = NULL;
- free(this->previous); this->previous = NULL;
+ free(this->reusable), this->reusable = NULL;
+ free(this->values), this->values = NULL;
+ free(this->next), this->next = NULL;
+ free(this->previous), this->previous = NULL;
}
@@ -122,10 +122,10 @@ int linked_list_clone(const linked_list_t* restrict this, linked_list_t* restric
out->previous = NULL;
out->reusable = NULL;
- if ((new_values = malloc(n)) == NULL) goto fail;
- if ((new_next = malloc(n)) == NULL) goto fail;
- if ((new_previous = malloc(n)) == NULL) goto fail;
- if ((new_reusable = malloc(n)) == NULL) goto fail;
+ fail_if ((new_values = malloc(n)) == NULL);
+ fail_if ((new_next = malloc(n)) == NULL);
+ fail_if ((new_previous = malloc(n)) == NULL);
+ fail_if ((new_reusable = malloc(n)) == NULL);
out->values = new_values;
out->next = new_next;
@@ -144,7 +144,7 @@ int linked_list_clone(const linked_list_t* restrict this, linked_list_t* restric
return 0;
- fail:
+ pfail:
free(new_values);
free(new_next);
free(new_previous);
@@ -191,9 +191,9 @@ int linked_list_pack(linked_list_t* restrict this)
if (cap != this->capacity)
{
- if (xmalloc(new_next, cap, ssize_t)) goto fail;
- if (xmalloc(new_previous, cap, ssize_t)) goto fail;
- if (xmalloc(new_reusable, cap, ssize_t)) goto fail;
+ fail_if (xmalloc(new_next, cap, ssize_t));
+ fail_if (xmalloc(new_previous, cap, ssize_t));
+ fail_if (xmalloc(new_reusable, cap, ssize_t));
free(this->next);
free(this->previous);
@@ -218,7 +218,7 @@ int linked_list_pack(linked_list_t* restrict this)
return 0;
- fail:
+ pfail:
free(vals);
free(new_next);
free(new_previous);