xmalloc: add xmemdup() and use to replace some uses of xmalloc+memcpy

This commit is contained in:
Craig Barnes 2024-03-16 20:28:10 +00:00 committed by Daniel Eklöf
parent 853be450bb
commit e8b04e0e2c
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
4 changed files with 14 additions and 18 deletions

View file

@ -51,11 +51,8 @@ static void
enqueue_data_for_slave(const void *data, size_t len, size_t offset,
ptmx_buffer_list_t *buffer_list)
{
void *copy = xmalloc(len);
memcpy(copy, data, len);
struct ptmx_buffer queued = {
.data = copy,
.data = xmemdup(data, len),
.len = len,
.idx = offset,
};