From: Kenneth Graunke Date: Wed, 18 Sep 2013 21:05:36 +0000 (-0700) Subject: glsl: Use the new DECLARE_R[Z]ALLOC_CXX_OPERATORS in a bunch of places. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=81a3759bb51a1a12ba1c6c6ad586c5ff5f31c411;p=mesa.git glsl: Use the new DECLARE_R[Z]ALLOC_CXX_OPERATORS in a bunch of places. This eliminates a lot of boilerplate and should be 100% equivalent. Signed-off-by: Kenneth Graunke Reviewed-by: Eric Anholt Reviewed-by: Chad Versace Reviewed-by: Ian Romanick --- diff --git a/src/glsl/ast.h b/src/glsl/ast.h index 1c7fc63ac24..c3361a10662 100644 --- a/src/glsl/ast.h +++ b/src/glsl/ast.h @@ -49,24 +49,7 @@ struct YYLTYPE; */ class ast_node { public: - /* Callers of this ralloc-based new need not call delete. It's - * easier to just ralloc_free 'ctx' (or any of its ancestors). */ - static void* operator new(size_t size, void *ctx) - { - void *node; - - node = rzalloc_size(ctx, size); - assert(node != NULL); - - return node; - } - - /* If the user *does* call delete, that's OK, we will just - * ralloc_free in that case. */ - static void operator delete(void *table) - { - ralloc_free(table); - } + DECLARE_RZALLOC_CXX_OPERATORS(ast_node); /** * Print an AST node in something approximating the original GLSL code @@ -363,24 +346,7 @@ enum { }; struct ast_type_qualifier { - /* Callers of this ralloc-based new need not call delete. It's - * easier to just ralloc_free 'ctx' (or any of its ancestors). */ - static void* operator new(size_t size, void *ctx) - { - void *node; - - node = rzalloc_size(ctx, size); - assert(node != NULL); - - return node; - } - - /* If the user *does* call delete, that's OK, we will just - * ralloc_free in that case. */ - static void operator delete(void *table) - { - ralloc_free(table); - } + DECLARE_RZALLOC_CXX_OPERATORS(ast_type_qualifier); union { struct { diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h index 2e2440a9eed..364a983458a 100644 --- a/src/glsl/glsl_parser_extras.h +++ b/src/glsl/glsl_parser_extras.h @@ -73,22 +73,7 @@ struct _mesa_glsl_parse_state { _mesa_glsl_parse_state(struct gl_context *_ctx, GLenum target, void *mem_ctx); - /* Callers of this ralloc-based new need not call delete. It's - * easier to just ralloc_free 'ctx' (or any of its ancestors). */ - static void* operator new(size_t size, void *ctx) - { - void *mem = rzalloc_size(ctx, size); - assert(mem != NULL); - - return mem; - } - - /* If the user *does* call delete, that's OK, we will just - * ralloc_free in that case. */ - static void operator delete(void *mem) - { - ralloc_free(mem); - } + DECLARE_RZALLOC_CXX_OPERATORS(_mesa_glsl_parse_state); /** * Generate a string representing the GLSL version currently being compiled diff --git a/src/glsl/glsl_symbol_table.cpp b/src/glsl/glsl_symbol_table.cpp index 4c96620bfdb..6e916b458d6 100644 --- a/src/glsl/glsl_symbol_table.cpp +++ b/src/glsl/glsl_symbol_table.cpp @@ -26,20 +26,7 @@ class symbol_table_entry { public: - /* Callers of this ralloc-based new need not call delete. It's - * easier to just ralloc_free 'ctx' (or any of its ancestors). */ - static void* operator new(size_t size, void *ctx) - { - void *entry = ralloc_size(ctx, size); - assert(entry != NULL); - return entry; - } - - /* If the user *does* call delete, that's OK, we will just ralloc_free. */ - static void operator delete(void *entry) - { - ralloc_free(entry); - } + DECLARE_RALLOC_CXX_OPERATORS(symbol_table_entry); bool add_interface(const glsl_type *i, enum ir_variable_mode mode) { diff --git a/src/glsl/ir_function_detect_recursion.cpp b/src/glsl/ir_function_detect_recursion.cpp index 280c4734ad2..b02c32518cc 100644 --- a/src/glsl/ir_function_detect_recursion.cpp +++ b/src/glsl/ir_function_detect_recursion.cpp @@ -139,25 +139,7 @@ public: /* empty */ } - - /* Callers of this ralloc-based new need not call delete. It's - * easier to just ralloc_free 'ctx' (or any of its ancestors). */ - static void* operator new(size_t size, void *ctx) - { - void *node; - - node = ralloc_size(ctx, size); - assert(node != NULL); - - return node; - } - - /* If the user *does* call delete, that's OK, we will just - * ralloc_free in that case. */ - static void operator delete(void *node) - { - ralloc_free(node); - } + DECLARE_RALLOC_CXX_OPERATORS(function) ir_function_signature *sig; diff --git a/src/glsl/list.h b/src/glsl/list.h index 1d46365faec..5ac17cb37a4 100644 --- a/src/glsl/list.h +++ b/src/glsl/list.h @@ -76,24 +76,7 @@ struct exec_node { struct exec_node *prev; #ifdef __cplusplus - /* Callers of this ralloc-based new need not call delete. It's - * easier to just ralloc_free 'ctx' (or any of its ancestors). */ - static void* operator new(size_t size, void *ctx) - { - void *node; - - node = ralloc_size(ctx, size); - assert(node != NULL); - - return node; - } - - /* If the user *does* call delete, that's OK, we will just - * ralloc_free in that case. */ - static void operator delete(void *node) - { - ralloc_free(node); - } + DECLARE_RALLOC_CXX_OPERATORS(exec_node) exec_node() : next(NULL), prev(NULL) { @@ -285,24 +268,7 @@ struct exec_list { struct exec_node *tail_pred; #ifdef __cplusplus - /* Callers of this ralloc-based new need not call delete. It's - * easier to just ralloc_free 'ctx' (or any of its ancestors). */ - static void* operator new(size_t size, void *ctx) - { - void *node; - - node = ralloc_size(ctx, size); - assert(node != NULL); - - return node; - } - - /* If the user *does* call delete, that's OK, we will just - * ralloc_free in that case. */ - static void operator delete(void *node) - { - ralloc_free(node); - } + DECLARE_RALLOC_CXX_OPERATORS(exec_list) exec_list() {