| 85 | #define CHECK_NULL(ptr, ...) if ((ptr) == NULL) { __VA_ARGS__; return NULL; } |
| 86 | |
| 87 | static te_expr *new_expr(const int type, const te_expr *parameters[]) { |
| 88 | const int arity = ARITY(type); |
| 89 | const int psize = sizeof(void*) * arity; |
| 90 | const int size = (sizeof(te_expr) - sizeof(void*)) + psize + (IS_CLOSURE(type) ? sizeof(void*) : 0); |
| 91 | te_expr *ret = malloc(size); |
| 92 | CHECK_NULL(ret); |
| 93 | |
| 94 | memset(ret, 0, size); |
| 95 | if (arity && parameters) { |
| 96 | memcpy(ret->parameters, parameters, psize); |
| 97 | } |
| 98 | ret->type = type; |
| 99 | ret->bound = 0; |
| 100 | return ret; |
| 101 | } |
| 102 | |
| 103 | |
| 104 | void te_free_parameters(te_expr *n) { |