aboutsummaryrefslogtreecommitdiffstats
path: root/src/mds-clipboard.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/mds-clipboard.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/mds-clipboard.c6
1 files changed, 2 insertions, 4 deletions
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);