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/mds-clipboard.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/mds-clipboard.c') diff --git a/src/mds-clipboard.c b/src/mds-clipboard.c index 50ee6a3..a2c3a0f 100644 --- a/src/mds-clipboard.c +++ b/src/mds-clipboard.c @@ -299,8 +299,7 @@ int unmarshal_server(char* state_buf) buf_get_next(state_buf, long, clip->dethklok.tv_nsec); buf_get_next(state_buf, uint64_t, clip->client); buf_get_next(state_buf, int, clip->autopurge); - fail_if (xmalloc(clip->content, clip->length, char)); - memcpy(clip->content, state_buf, clip->length * sizeof(char)); + fail_if (xmemdup(clip->content, state_buf, clip->length, char)); state_buf += clip->length; } } @@ -721,8 +720,7 @@ int clipboard_add(int level, const char* time_to_live, const char* recv_client_i new_clip.autopurge = autopurge; new_clip.length = received.payload_size; - fail_if (xmalloc(new_clip.content, new_clip.length, char)); - memcpy(new_clip.content, received.payload, new_clip.length * sizeof(char)); + fail_if (xmemdup(new_clip.content, received.payload, new_clip.length, char)); if (clipboard_used[level] == clipboard_size[level]) free_clipboard_entry(clipboard[level] + clipboard_used[level] - 1); -- cgit v1.2.3-70-g09d2