aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmdsserver/client-list.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libmdsserver/client-list.c')
-rw-r--r--src/libmdsserver/client-list.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/libmdsserver/client-list.c b/src/libmdsserver/client-list.c
index ff3ffe2..24403cb 100644
--- a/src/libmdsserver/client-list.c
+++ b/src/libmdsserver/client-list.c
@@ -70,10 +70,11 @@ int client_list_create(client_list_t* restrict this, size_t capacity)
this->capacity = capacity = to_power_of_two(capacity);
this->size = 0;
this->clients = NULL;
- if (xmalloc(this->clients, capacity, uint64_t))
- return -1;
+ fail_if (xmalloc(this->clients, capacity, uint64_t));
return 0;
+ fail:
+ return -1;
}
@@ -139,12 +140,14 @@ int client_list_add(client_list_t* restrict this, uint64_t client)
{
this->capacity >>= 1;
this->clients = old;
- return -1;
+ fail_if (1);
}
}
this->clients[this->size++] = client;
return 0;
+ fail:
+ return -1;
}
@@ -230,13 +233,14 @@ int client_list_unmarshal(client_list_t* restrict this, char* restrict data)
n = this->capacity * sizeof(uint64_t);
- if ((this->clients = malloc(n)) == NULL)
- return -1;
+ fail_if ((this->clients = malloc(n)) == NULL);
n = this->size * sizeof(uint64_t);
memcpy(this->clients, data, n);
return 0;
+ fail:
+ return -1;
}