vkd3d-shader/hlsl: Introduce hlsl_calloc().

This is just a wrapper of vkd3d_calloc(), that has the advantage of
checking for multiplication overflow.
This commit is contained in:
Francisco Casas
2023-05-03 15:39:58 -04:00
committed by Alexandre Julliard
parent ef7cf9b1ad
commit fd38c58112
Notes: Alexandre Julliard 2023-05-08 22:34:16 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Zebediah Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/159
2 changed files with 12 additions and 3 deletions

View File

@@ -939,6 +939,15 @@ static inline void *hlsl_alloc(struct hlsl_ctx *ctx, size_t size)
return ptr;
}
static inline void *hlsl_calloc(struct hlsl_ctx *ctx, size_t count, size_t size)
{
void *ptr = vkd3d_calloc(count, size);
if (!ptr)
ctx->result = VKD3D_ERROR_OUT_OF_MEMORY;
return ptr;
}
static inline void *hlsl_realloc(struct hlsl_ctx *ctx, void *ptr, size_t size)
{
void *ret = vkd3d_realloc(ptr, size);