summaryrefslogtreecommitdiff
path: root/ast.h
diff options
context:
space:
mode:
Diffstat (limited to 'ast.h')
-rw-r--r--ast.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/ast.h b/ast.h
index 782e2c7ce7..de300e719c 100644
--- a/ast.h
+++ b/ast.h
@@ -36,6 +36,25 @@ struct YYLTYPE;
class ast_node {
public:
+ /* Callers of this talloc-based new need not call delete. It's
+ * easier to just talloc_free 'ctx' (or any of its ancestors). */
+ static void* operator new(size_t size, void *ctx)
+ {
+ void *node;
+
+ node = talloc_size(ctx, size);
+ assert(node != NULL);
+
+ return node;
+ }
+
+ /* If the user *does* call delete, that's OK, we will just
+ * talloc_free in that case. */
+ static void operator delete(void *table)
+ {
+ talloc_free(table);
+ }
+
virtual void print(void) const;
virtual ir_rvalue *hir(exec_list *instructions,
struct _mesa_glsl_parse_state *state);