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:
Mike Hommey
2012-04-24 23:22:02 +02:00
committed by Jason Evans
parent f278994029
commit 8b49971d0c
7 changed files with 43 additions and 18 deletions

View File

@@ -542,8 +542,9 @@ prof_free(const void *ptr, size_t size)
cassert(config_prof);
if ((uintptr_t)ctx > (uintptr_t)1) {
prof_thr_cnt_t *tcnt;
assert(size == isalloc(ptr, true));
prof_thr_cnt_t *tcnt = prof_lookup(ctx->bt);
tcnt = prof_lookup(ctx->bt);
if (tcnt != NULL) {
tcnt->epoch++;