Quellcode durchsuchen

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>
tags/mesa-10.1-devel
Kenneth Graunke vor 12 Jahren
Ursprung
Commit
81a3759bb5

+ 2
- 36
src/glsl/ast.h Datei anzeigen

@@ -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 {

+ 1
- 16
src/glsl/glsl_parser_extras.h Datei anzeigen

@@ -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

+ 1
- 14
src/glsl/glsl_symbol_table.cpp Datei anzeigen

@@ -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)
{

+ 1
- 19
src/glsl/ir_function_detect_recursion.cpp Datei anzeigen

@@ -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;


+ 2
- 36
src/glsl/list.h Datei anzeigen

@@ -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()
{

Laden…
Abbrechen
Speichern