Skip to content

Commit f1bf5b6

Browse files
committed
Use flexible array notation for te_expr
Newer gcc gets confused when malloc stores a bunch of memory in a one-element array. C99 "flexible array" notation achieves the same effect in a more standard way.
1 parent 4e8cc00 commit f1bf5b6

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

tinyexpr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ typedef struct state {
8686
static te_expr *new_expr(const int type, const te_expr *parameters[]) {
8787
const int arity = ARITY(type);
8888
const int psize = sizeof(void*) * arity;
89-
const int size = (sizeof(te_expr) - sizeof(void*)) + psize + (IS_CLOSURE(type) ? sizeof(void*) : 0);
89+
const int size = sizeof(te_expr) + psize + (IS_CLOSURE(type) ? sizeof(void*) : 0);
9090
te_expr *ret = malloc(size);
9191
memset(ret, 0, size);
9292
if (arity && parameters) {

tinyexpr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ extern "C" {
3636
typedef struct te_expr {
3737
int type;
3838
union {double value; const double *bound; const void *function;};
39-
void *parameters[1];
39+
void *parameters[];
4040
} te_expr;
4141

4242

0 commit comments

Comments
 (0)