mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 04:48:08 +02:00
glsl: make consistent use of DECLARE_RALLOC_CXX_OPERATORS
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
parent
4111b1d54b
commit
3914dc579e
2 changed files with 2 additions and 46 deletions
|
|
@ -43,37 +43,8 @@ struct glsl_type;
|
|||
* type safe and some symbol table invariants.
|
||||
*/
|
||||
struct glsl_symbol_table {
|
||||
private:
|
||||
static void
|
||||
_glsl_symbol_table_destructor (glsl_symbol_table *table)
|
||||
{
|
||||
table->~glsl_symbol_table();
|
||||
}
|
||||
DECLARE_RALLOC_CXX_OPERATORS(glsl_symbol_table)
|
||||
|
||||
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 *table;
|
||||
|
||||
table = ralloc_size(ctx, size);
|
||||
assert(table != NULL);
|
||||
|
||||
ralloc_set_destructor(table, (void (*)(void*)) _glsl_symbol_table_destructor);
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
/* If the user *does* call delete, that's OK, we will just
|
||||
* ralloc_free in that case. Here, C++ will have already called the
|
||||
* destructor so tell ralloc not to do that again. */
|
||||
static void operator delete(void *table)
|
||||
{
|
||||
ralloc_set_destructor(table, NULL);
|
||||
ralloc_free(table);
|
||||
}
|
||||
|
||||
glsl_symbol_table();
|
||||
~glsl_symbol_table();
|
||||
|
||||
|
|
|
|||
|
|
@ -140,22 +140,7 @@ public:
|
|||
hash_table_dtor(this->var_hash);
|
||||
}
|
||||
|
||||
static void* operator new(size_t size, void *ctx)
|
||||
{
|
||||
void *lvs = ralloc_size(ctx, size);
|
||||
assert(lvs != NULL);
|
||||
|
||||
ralloc_set_destructor(lvs, (void (*)(void*)) destructor);
|
||||
|
||||
return lvs;
|
||||
}
|
||||
|
||||
private:
|
||||
static void
|
||||
destructor(loop_variable_state *lvs)
|
||||
{
|
||||
lvs->~loop_variable_state();
|
||||
}
|
||||
DECLARE_RALLOC_CXX_OPERATORS(loop_variable_state)
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue