mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 21:50:12 +01:00
glsl: Hook up loop_variable_state destructor to plug a memory leak.
While ~loop_state() is already freeing the loop_variable_state objects via ralloc_free(this->mem_ctx), the ~loop_variable_state() destructor was never getting called, so the hash table inside loop_variable_state was never getting destroyed. Fixes a memory leak in any shader with loops. NOTE: This is a candidate for stable release branches. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
parent
5f3f63b76d
commit
3603fdcebf
1 changed files with 17 additions and 0 deletions
|
|
@ -140,6 +140,23 @@ 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();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue