Giovanni Mascellani (@giomasce) commented about libs/vkd3d-shader/tpf.c:
if (var->objects_usage[regset][regset_offset].used)
{
if (!(name_buffer = hlsl_component_to_string(ctx, var, k)))
{
sm4_free_extern_resources(extern_resources, *count);
*count = 0;
return NULL;
}
if (!(name = hlsl_strdup(ctx, name_buffer->buffer)))
{
sm4_free_extern_resources(extern_resources, *count);
*count = 0;
hlsl_release_string_buffer(ctx, name_buffer);
return NULL;
}
hlsl_release_string_buffer(ctx, name_buffer);
This pattern is rather common. I doubt the performance impact is significant, but mostly with the goal of simplifying error management I wonder if we should introduce some function that resets the string buffer and returns its previous buffer, so that we can avoid duplicating a string just to free the original immediately after.
Not necessarily for this MR, of course.