mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
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:
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
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user