diff --git a/tinyexpr.c b/tinyexpr.c index bee3cfd..72bcc8f 100755 --- a/tinyexpr.c +++ b/tinyexpr.c @@ -86,7 +86,7 @@ typedef struct state { static te_expr *new_expr(const int type, const te_expr *parameters[]) { const int arity = ARITY(type); const int psize = sizeof(void*) * arity; - const int size = (sizeof(te_expr) - sizeof(void*)) + psize + (IS_CLOSURE(type) ? sizeof(void*) : 0); + const int size = sizeof(te_expr) + psize + (IS_CLOSURE(type) ? sizeof(void*) : 0); te_expr *ret = malloc(size); memset(ret, 0, size); if (arity && parameters) { diff --git a/tinyexpr.h b/tinyexpr.h index c2cbe1a..6d3d4b0 100644 --- a/tinyexpr.h +++ b/tinyexpr.h @@ -36,7 +36,7 @@ extern "C" { typedef struct te_expr { int type; union {double value; const double *bound; const void *function;}; - void *parameters[1]; + void *parameters[]; } te_expr;