After moving ast_instantiate up, the checks which return NULL now must mem_d(self)

This commit is contained in:
Wolfgang Bumiller 2012-04-29 00:41:35 +02:00
parent 674ae4b7da
commit 5751e41993

13
ast.c
View file

@ -181,13 +181,14 @@ void ast_block_delete(ast_block *self)
ast_function* ast_function_new(lex_ctx ctx, const char *name, ast_value *vtype)
{
ast_instantiate(ast_function, ctx, ast_function_delete);
if (!vtype)
return NULL;
if (vtype->isconst)
return NULL;
if (vtype->vtype != TYPE_FUNCTION)
if (!vtype ||
vtype->isconst ||
vtype->vtype != TYPE_FUNCTION)
{
mem_d(self);
return NULL;
}
self->vtype = vtype;
self->name = name ? util_strdup(name) : NULL;