diff options
author | Simon Ser <contact@emersion.fr> | 2023-08-03 12:07:27 +0200 |
---|---|---|
committer | Alexander Orzechowski <alex@ozal.ski> | 2023-08-03 14:40:28 +0000 |
commit | c74f89d4f84bfed0284d3908aee5d207698c70c5 (patch) | |
tree | 6ded2e7ac9010daf75437ffd6ad45f0659412bbf /render/allocator/gbm.c | |
parent | 77dc1c28aa551616521b60f1a8727a25a45f82e1 (diff) |
Avoid using memcpy() to copy structs
We can just use a regular assignment instead. This is more
type-safe since there is no need to provide the struct size.
The remaining memcpy() calls perform array copies or copies from
void pointers (which may be unaligned).
Diffstat (limited to 'render/allocator/gbm.c')
-rw-r--r-- | render/allocator/gbm.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/render/allocator/gbm.c b/render/allocator/gbm.c index 32636d30..25ddbbae 100644 --- a/render/allocator/gbm.c +++ b/render/allocator/gbm.c @@ -79,7 +79,7 @@ static bool export_gbm_bo(struct gbm_bo *bo, attribs.stride[i] = gbm_bo_get_stride_for_plane(bo, i); } - memcpy(out, &attribs, sizeof(attribs)); + *out = attribs; return true; error_fd: @@ -168,7 +168,7 @@ static bool buffer_get_dmabuf(struct wlr_buffer *wlr_buffer, struct wlr_dmabuf_attributes *attribs) { struct wlr_gbm_buffer *buffer = get_gbm_buffer_from_buffer(wlr_buffer); - memcpy(attribs, &buffer->dmabuf, sizeof(buffer->dmabuf)); + *attribs = buffer->dmabuf; return true; } |