From df1c94dd60bbd822d5615a1782dba9cec2ad3fa3 Mon Sep 17 00:00:00 2001 From: Elizabeth Figura Date: Tue, 2 Sep 2025 18:04:37 -0500 Subject: [PATCH] vkd3d-shader: Document the null terminator appended for textual formats. vkd3d_string_buffer uses vsnprintf() and therefore null-terminates when appending, so no code changes are necessary. --- include/vkd3d_shader.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/include/vkd3d_shader.h b/include/vkd3d_shader.h index a1f85dbbd..3a2f54c8f 100644 --- a/include/vkd3d_shader.h +++ b/include/vkd3d_shader.h @@ -422,10 +422,17 @@ struct vkd3d_shader_code { /** * Pointer to the code. Note that textual formats are not null-terminated. - * Therefore \a size should not include a null terminator, when this - * structure is passed as input to a vkd3d-shader function, and the - * allocated string will not include a null terminator when this structure - * is used as output. + * Therefore \a size should not include a null terminator when this + * structure is passed as input to a vkd3d-shader function, and \a size + * will not include a null terminator when this structure is used as + * output. + * + * For convenience, vkd3d_shader_preprocess() and vkd3d_shader_compile() + * will append a null terminator past the end of their output when + * outputting textual formats like VKD3D_SHADER_TARGET_D3D_ASM. This makes + * it safe to call functions like strlen() on \a code for such output, + * although doing so will obviously not account for any embedded null + * characters that may be present. */ const void *code; /** Size of \a code, in bytes. */