Zebediah Figura : vkd3d-shader/hlsl: Pass the original name string to hlsl_new_type().
Alexandre Julliard
julliard at winehq.org
Fri Oct 1 18:00:41 CDT 2021
Module: vkd3d
Branch: master
Commit: a1f938e8e41cca53148ad4fd9d2d198ec02f9092
URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=a1f938e8e41cca53148ad4fd9d2d198ec02f9092
Author: Zebediah Figura <zfigura at codeweavers.com>
Date: Mon Sep 27 20:51:47 2021 -0500
vkd3d-shader/hlsl: Pass the original name string to hlsl_new_type().
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
libs/vkd3d-shader/hlsl.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c
index fc6d1e4..66ca389 100644
--- a/libs/vkd3d-shader/hlsl.c
+++ b/libs/vkd3d-shader/hlsl.c
@@ -207,7 +207,11 @@ static struct hlsl_type *hlsl_new_type(struct hlsl_ctx *ctx, const char *name, e
if (!(type = hlsl_alloc(ctx, sizeof(*type))))
return NULL;
- type->name = name;
+ if (!(type->name = hlsl_strdup(ctx, name)))
+ {
+ vkd3d_free(type);
+ return NULL;
+ }
type->type = type_class;
type->base_type = base_type;
type->dimx = dimx;
@@ -1656,21 +1660,21 @@ static void declare_predefined_types(struct hlsl_ctx *ctx)
for (x = 1; x <= 4; ++x)
{
sprintf(name, "%s%ux%u", names[bt], y, x);
- type = hlsl_new_type(ctx, hlsl_strdup(ctx, name), HLSL_CLASS_MATRIX, bt, x, y);
+ type = hlsl_new_type(ctx, name, HLSL_CLASS_MATRIX, bt, x, y);
hlsl_scope_add_type(ctx->globals, type);
ctx->builtin_types.matrix[bt][x - 1][y - 1] = type;
if (y == 1)
{
sprintf(name, "%s%u", names[bt], x);
- type = hlsl_new_type(ctx, hlsl_strdup(ctx, name), HLSL_CLASS_VECTOR, bt, x, y);
+ type = hlsl_new_type(ctx, name, HLSL_CLASS_VECTOR, bt, x, y);
hlsl_scope_add_type(ctx->globals, type);
ctx->builtin_types.vector[bt][x - 1] = type;
if (x == 1)
{
sprintf(name, "%s", names[bt]);
- type = hlsl_new_type(ctx, hlsl_strdup(ctx, name), HLSL_CLASS_SCALAR, bt, x, y);
+ type = hlsl_new_type(ctx, name, HLSL_CLASS_SCALAR, bt, x, y);
hlsl_scope_add_type(ctx->globals, type);
ctx->builtin_types.scalar[bt] = type;
}
@@ -1681,16 +1685,16 @@ static void declare_predefined_types(struct hlsl_ctx *ctx)
for (bt = 0; bt <= HLSL_SAMPLER_DIM_MAX; ++bt)
{
- type = hlsl_new_type(ctx, hlsl_strdup(ctx, sampler_names[bt]), HLSL_CLASS_OBJECT, HLSL_TYPE_SAMPLER, 1, 1);
+ type = hlsl_new_type(ctx, sampler_names[bt], HLSL_CLASS_OBJECT, HLSL_TYPE_SAMPLER, 1, 1);
type->sampler_dim = bt;
ctx->builtin_types.sampler[bt] = type;
}
- ctx->builtin_types.Void = hlsl_new_type(ctx, hlsl_strdup(ctx, "void"), HLSL_CLASS_OBJECT, HLSL_TYPE_VOID, 1, 1);
+ ctx->builtin_types.Void = hlsl_new_type(ctx, "void", HLSL_CLASS_OBJECT, HLSL_TYPE_VOID, 1, 1);
for (i = 0; i < ARRAY_SIZE(effect_types); ++i)
{
- type = hlsl_new_type(ctx, hlsl_strdup(ctx, effect_types[i].name), effect_types[i].class,
+ type = hlsl_new_type(ctx, effect_types[i].name, effect_types[i].class,
effect_types[i].base_type, effect_types[i].dimx, effect_types[i].dimy);
hlsl_scope_add_type(ctx->globals, type);
}
More information about the wine-cvs
mailing list