mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-04 04:06:06 -05:00
xmalloc: add xmemdup() and use to replace some uses of xmalloc+memcpy
This commit is contained in:
parent
853be450bb
commit
e8b04e0e2c
4 changed files with 14 additions and 18 deletions
6
grid.c
6
grid.c
|
|
@ -263,8 +263,7 @@ grid_snapshot(const struct grid *grid)
|
|||
int original_stride = stride_for_format_and_width(original_pix_fmt, original_width);
|
||||
|
||||
size_t original_size = original_stride * original_height;
|
||||
void *new_original_data = xmalloc(original_size);
|
||||
memcpy(new_original_data, it->item.original.data, original_size);
|
||||
void *new_original_data = xmemdup(it->item.original.data, original_size);
|
||||
|
||||
pixman_image_t *new_original_pix = pixman_image_create_bits_no_clear(
|
||||
original_pix_fmt, original_width, original_height,
|
||||
|
|
@ -284,8 +283,7 @@ grid_snapshot(const struct grid *grid)
|
|||
int scaled_stride = stride_for_format_and_width(scaled_pix_fmt, scaled_width);
|
||||
|
||||
size_t scaled_size = scaled_stride * scaled_height;
|
||||
new_scaled_data = xmalloc(scaled_size);
|
||||
memcpy(new_scaled_data, it->item.scaled.data, scaled_size);
|
||||
new_scaled_data = xmemdup(it->item.scaled.data, scaled_size);
|
||||
|
||||
new_scaled_pix = pixman_image_create_bits_no_clear(
|
||||
scaled_pix_fmt, scaled_width, scaled_height, new_scaled_data,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue