From 344273a7e0a6899451836e6072fecebea4a6ac24 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 10 Dec 2014 02:58:25 +0100 Subject: add xmemdup macro MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/libmdsserver/client-list.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'src/libmdsserver/client-list.c') diff --git a/src/libmdsserver/client-list.c b/src/libmdsserver/client-list.c index 33b6844..f06b9b5 100644 --- a/src/libmdsserver/client-list.c +++ b/src/libmdsserver/client-list.c @@ -100,27 +100,15 @@ void client_list_destroy(client_list_t* restrict this) */ int client_list_clone(const client_list_t* restrict this, client_list_t* restrict out) { - size_t n = this->capacity * sizeof(uint64_t); - uint64_t* restrict new_clients = NULL; - int saved_errno; - - out->clients = NULL; - - fail_if (xbmalloc(new_clients, n)); - - out->clients = new_clients; + fail_if (xmemdup(out->clients, this->clients, this->capacity, uint64_t)); out->capacity = this->capacity; out->size = this->size; - memcpy(out->clients, this->clients, n); - return 0; fail: - saved_errno = errno; - free(new_clients); - return errno = saved_errno, -1; + return -1; } -- cgit v1.2.3-70-g09d2