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 <kenneth@whitecape.org> Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Chad Versace <chad.versace@linux.intel.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
This commit is contained in:
@@ -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 {
|
||||
|
@@ -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
|
||||
|
@@ -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)
|
||||
{
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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()
|
||||
{
|
||||
|
Reference in New Issue
Block a user