mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-25 06:05:58 +01:00
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).
This commit is contained in:
parent
77dc1c28aa
commit
c74f89d4f8
6 changed files with 7 additions and 7 deletions
|
@ -129,7 +129,7 @@ static void drm_dumb_buffer_end_data_ptr_access(struct wlr_buffer *wlr_buffer) {
|
|||
static bool buffer_get_dmabuf(struct wlr_buffer *wlr_buffer,
|
||||
struct wlr_dmabuf_attributes *attribs) {
|
||||
struct wlr_drm_dumb_buffer *buf = drm_dumb_buffer_from_buffer(wlr_buffer);
|
||||
memcpy(attribs, &buf->dmabuf, sizeof(buf->dmabuf));
|
||||
*attribs = buf->dmabuf;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ static void buffer_destroy(struct wlr_buffer *wlr_buffer) {
|
|||
static bool buffer_get_shm(struct wlr_buffer *wlr_buffer,
|
||||
struct wlr_shm_attributes *shm) {
|
||||
struct wlr_shm_buffer *buffer = shm_buffer_from_buffer(wlr_buffer);
|
||||
memcpy(shm, &buffer->shm, sizeof(*shm));
|
||||
*shm = buffer->shm;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ void wlr_dmabuf_attributes_finish(struct wlr_dmabuf_attributes *attribs) {
|
|||
|
||||
bool wlr_dmabuf_attributes_copy(struct wlr_dmabuf_attributes *dst,
|
||||
const struct wlr_dmabuf_attributes *src) {
|
||||
memcpy(dst, src, sizeof(struct wlr_dmabuf_attributes));
|
||||
*dst = *src;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < src->n_planes; ++i) {
|
||||
|
|
|
@ -330,7 +330,7 @@ static void surface_state_move(struct wlr_surface_state *state,
|
|||
pixman_region32_copy(&state->input, &next->input);
|
||||
}
|
||||
if (next->committed & WLR_SURFACE_STATE_VIEWPORT) {
|
||||
memcpy(&state->viewport, &next->viewport, sizeof(state->viewport));
|
||||
state->viewport = next->viewport;
|
||||
}
|
||||
if (next->committed & WLR_SURFACE_STATE_FRAME_CALLBACK_LIST) {
|
||||
wl_list_insert_list(&state->frame_callback_list,
|
||||
|
|
|
@ -111,7 +111,7 @@ static bool buffer_get_dmabuf(struct wlr_buffer *wlr_buffer,
|
|||
struct wlr_dmabuf_attributes *attribs) {
|
||||
struct wlr_dmabuf_v1_buffer *buffer =
|
||||
dmabuf_v1_buffer_from_buffer(wlr_buffer);
|
||||
memcpy(attribs, &buffer->attributes, sizeof(buffer->attributes));
|
||||
*attribs = buffer->attributes;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue