X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=blobdiff_plain;f=ast.c;h=c68ba9f065eecca940f1ef92c9b46e0989095613;hp=4eb250fad19c360756aae26a362d5cc063bdbe3f;hb=b3e87c328009c3c5b1b700d600733906d7792f59;hpb=e2c424d607a319ae76be8161a734a96fa285e99f diff --git a/ast.c b/ast.c index 4eb250f..c68ba9f 100644 --- a/ast.c +++ b/ast.c @@ -406,13 +406,17 @@ ast_binary* ast_binary_new(lex_ctx ctx, int op, else self->expression.vtype = left->expression.vtype; + /* references all */ + self->refs = AST_REF_ALL; + return self; } void ast_binary_delete(ast_binary *self) { - ast_unref(self->left); - ast_unref(self->right); + if (self->refs & AST_REF_LEFT) ast_unref(self->left); + if (self->refs & AST_REF_RIGHT) ast_unref(self->right); + ast_expression_delete((ast_expression*)self); mem_d(self); }