From 4d8e2d658acd56c1df793a17bf0e30e0a019b5f0 Mon Sep 17 00:00:00 2001 From: Elizabeth Figura Date: Fri, 15 Aug 2025 18:31:43 -0500 Subject: [PATCH] vkd3d-shader/preproc: Do not make a copy of the buffer before returning it. --- libs/vkd3d-shader/preproc.l | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/libs/vkd3d-shader/preproc.l b/libs/vkd3d-shader/preproc.l index a8c0db358..8913e5728 100644 --- a/libs/vkd3d-shader/preproc.l +++ b/libs/vkd3d-shader/preproc.l @@ -823,7 +823,6 @@ int preproc_lexer_parse(const struct vkd3d_shader_compile_info *compile_info, static const struct vkd3d_shader_preprocess_info default_preprocess_info = {0}; struct preproc_ctx ctx = {0}; char *source_name = NULL; - void *output_code; unsigned int i; vkd3d_string_buffer_init(&ctx.buffer); @@ -900,16 +899,9 @@ int preproc_lexer_parse(const struct vkd3d_shader_compile_info *compile_info, return VKD3D_ERROR_INVALID_SHADER; } - if (!(output_code = vkd3d_malloc(ctx.buffer.content_size))) - { - vkd3d_string_buffer_cleanup(&ctx.buffer); - return VKD3D_ERROR_OUT_OF_MEMORY; - } - memcpy(output_code, ctx.buffer.buffer, ctx.buffer.content_size); - out->size = ctx.buffer.content_size; - out->code = output_code; vkd3d_string_buffer_trace(&ctx.buffer); - vkd3d_string_buffer_cleanup(&ctx.buffer); + + vkd3d_shader_code_from_string_buffer(out, &ctx.buffer); return VKD3D_OK; fail: