vulkan/util: Make STACK_ARRAY() work for arrays of pointers
And add an explicit cast on the pointer returned by malloc() to make C++ happy. Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14766>
This commit is contained in:
committed by
Marge Bot
parent
bb1fb07ecd
commit
7e0ab29cfd
@@ -279,8 +279,9 @@ vk_spec_info_to_nir_spirv(const VkSpecializationInfo *spec_info,
|
||||
#define STACK_ARRAY_SIZE 8
|
||||
|
||||
#define STACK_ARRAY(type, name, size) \
|
||||
type _stack_##name[STACK_ARRAY_SIZE] = {0}, *const name = \
|
||||
(size) <= STACK_ARRAY_SIZE ? _stack_##name : malloc((size) * sizeof(type))
|
||||
type _stack_##name[STACK_ARRAY_SIZE] = {0}; \
|
||||
type *const name = \
|
||||
((size) <= STACK_ARRAY_SIZE ? _stack_##name : (type *)malloc((size) * sizeof(type)))
|
||||
|
||||
#define STACK_ARRAY_FINISH(name) \
|
||||
if (name != _stack_##name) free(name)
|
||||
|
||||
Reference in New Issue
Block a user