diff options
author | Kenneth Graunke <kenneth@whitecape.org> | 2012-06-05 15:58:41 -0700 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2012-07-06 10:00:30 -0700 |
commit | 1edeb2cec1c92b73bef97c2a5f15be943a8379b2 (patch) | |
tree | 772650fc480ab753465146d1326e978bc32bacdb | |
parent | afaf5b59e45b914be39e141209ed71308039774d (diff) | |
download | mesa-1edeb2cec1c92b73bef97c2a5f15be943a8379b2.tar.gz |
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>
(cherry picked from commit 3603fdcebfa25e2217f1dbfb0a99261be3e84b02)
-rw-r--r-- | src/glsl/loop_analysis.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/glsl/loop_analysis.h b/src/glsl/loop_analysis.h index 229730836a8..d47b969136c 100644 --- a/src/glsl/loop_analysis.h +++ b/src/glsl/loop_analysis.h @@ -134,6 +134,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(); + } }; |