mirror of
https://github.com/Ryujinx/libsoundio.git
synced 2024-12-22 23:55:34 +00:00
ALLOCATE_* family macros cast to the destination type
They were previously evaluated as an expression of `void *` type. This allows a C++ compiler to assign it a variable of the destination type.
This commit is contained in:
parent
ce42b89da3
commit
ff1af0e4cb
|
@ -13,11 +13,11 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#define ALLOCATE_NONZERO(Type, count) malloc((count) * sizeof(Type))
|
#define ALLOCATE_NONZERO(Type, count) ((Type*)malloc((count) * sizeof(Type)))
|
||||||
|
|
||||||
#define ALLOCATE(Type, count) calloc(count, sizeof(Type))
|
#define ALLOCATE(Type, count) ((Type*)calloc(count, sizeof(Type)))
|
||||||
|
|
||||||
#define REALLOCATE_NONZERO(Type, old, new_count) realloc(old, (new_count) * sizeof(Type))
|
#define REALLOCATE_NONZERO(Type, old, new_count) ((Type*)realloc(old, (new_count) * sizeof(Type)))
|
||||||
|
|
||||||
#define ARRAY_LENGTH(array) (sizeof(array)/sizeof((array)[0]))
|
#define ARRAY_LENGTH(array) (sizeof(array)/sizeof((array)[0]))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue