Zebediah Figura : vkd3d-shader/hlsl: Introduce an allocation helper for vkd3d_realloc() as well.
Module: vkd3d Branch: master Commit: 2ebfa9106253871c2f25402e7287fb22cc73b324 URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=2ebfa9106253871c2f25402e... Author: Zebediah Figura <zfigura(a)codeweavers.com> Date: Mon Sep 20 16:40:11 2021 -0500 vkd3d-shader/hlsl: Introduce an allocation helper for vkd3d_realloc() as well. Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com> Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com> Signed-off-by: Giovanni Mascellani <gmascellani(a)codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- libs/vkd3d-shader/hlsl.h | 9 +++++++++ libs/vkd3d-shader/hlsl.y | 6 +++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 7079171..c69dc4a 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -559,6 +559,15 @@ static inline void *hlsl_alloc(struct hlsl_ctx *ctx, size_t size) return ptr; } +static inline void *hlsl_realloc(struct hlsl_ctx *ctx, void *ptr, size_t size) +{ + void *ret = vkd3d_realloc(ptr, size); + + if (!ret) + ctx->result = VKD3D_ERROR_OUT_OF_MEMORY; + return ret; +} + static inline char *hlsl_strdup(struct hlsl_ctx *ctx, const char *string) { char *ptr = vkd3d_strdup(string); diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 2206d64..dc2d310 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -1997,7 +1997,7 @@ preproc_directive: ctx->location.line = $1; if (strcmp($2, ctx->location.source_name)) - new_array = vkd3d_realloc(ctx->source_files, + new_array = hlsl_realloc(ctx, ctx->source_files, sizeof(*ctx->source_files) * (ctx->source_files_count + 1)); if (new_array) @@ -2544,7 +2544,7 @@ arrays: YYABORT; } - if (!(new_array = vkd3d_realloc($$.sizes, ($$.count + 1) * sizeof(*new_array)))) + if (!(new_array = hlsl_realloc(ctx, $$.sizes, ($$.count + 1) * sizeof(*new_array)))) { vkd3d_free($$.sizes); YYABORT; @@ -2636,7 +2636,7 @@ initializer_expr_list: | initializer_expr_list ',' initializer_expr { $$ = $1; - if (!($$.args = vkd3d_realloc($$.args, ($$.args_count + 1) * sizeof(*$$.args)))) + if (!($$.args = hlsl_realloc(ctx, $$.args, ($$.args_count + 1) * sizeof(*$$.args)))) YYABORT; $$.args[$$.args_count++] = node_from_list($3); list_move_tail($$.instrs, $3);
participants (1)
-
Alexandre Julliard