mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-08-25 00:23:33 +03:00
Avoid variable length arrays and remove declarations within code
MSVC doesn't support C99, and building as C++ to be able to use them is dangerous, as C++ and C99 are incompatible. Introduce a VARIABLE_ARRAY macro that either uses VLA when supported, or alloca() otherwise. Note that using alloca() inside loops doesn't quite work like VLAs, thus the use of VARIABLE_ARRAY there is discouraged. It might be worth investigating ways to check whether VARIABLE_ARRAY is used in such context at runtime in debug builds and bail out if that happens.
This commit is contained in:
parent
f278994029
commit
8b49971d0c
7 changed files with 43 additions and 18 deletions
|
|
@ -498,7 +498,7 @@ stats_print(void (*write_cb)(void *, const char *), void *cbopaque,
|
|||
|
||||
CTL_GET("arenas.narenas", &narenas, unsigned);
|
||||
{
|
||||
bool initialized[narenas];
|
||||
VARIABLE_ARRAY(bool, initialized, narenas);
|
||||
size_t isz;
|
||||
unsigned i, ninitialized;
|
||||
|
||||
|
|
@ -527,7 +527,7 @@ stats_print(void (*write_cb)(void *, const char *), void *cbopaque,
|
|||
|
||||
CTL_GET("arenas.narenas", &narenas, unsigned);
|
||||
{
|
||||
bool initialized[narenas];
|
||||
VARIABLE_ARRAY(bool, initialized, narenas);
|
||||
size_t isz;
|
||||
unsigned i;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue