From e8b04e0e2c9e8a4f825193b907d04c3b3165a842 Mon Sep 17 00:00:00 2001 From: Craig Barnes Date: Sat, 16 Mar 2024 20:28:10 +0000 Subject: xmalloc: add xmemdup() and use to replace some uses of xmalloc+memcpy --- grid.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'grid.c') diff --git a/grid.c b/grid.c index 03ceb0ec..85e6183f 100644 --- a/grid.c +++ b/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, -- cgit v1.3