aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmdsserver/client-list.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-12-10 02:58:25 +0100
committerMattias Andrée <maandree@operamail.com>2014-12-10 02:58:25 +0100
commit344273a7e0a6899451836e6072fecebea4a6ac24 (patch)
treeea24fa9e12ae6dad40eeb6470c92545e14f0f8cf /src/libmdsserver/client-list.c
parentno more direct allocations, always use macros, unless using alloca (diff)
downloadmds-344273a7e0a6899451836e6072fecebea4a6ac24.tar.gz
mds-344273a7e0a6899451836e6072fecebea4a6ac24.tar.bz2
mds-344273a7e0a6899451836e6072fecebea4a6ac24.tar.xz
add xmemdup macro
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/libmdsserver/client-list.c16
1 files changed, 2 insertions, 14 deletions
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;
}