glsl: Fix memory leak with known glsl_type instances
authorSimon Hausmann <simon.hausmann@qt.io>
Wed, 14 Feb 2018 11:51:11 +0000 (12:51 +0100)
committerTapani Pälli <tapani.palli@intel.com>
Wed, 7 Mar 2018 12:33:34 +0000 (14:33 +0200)
commitfb5825e7ceeb16ac05f870ffe1e5a5daa09e68dd
tree3ed3fdf3f06f789af7d00fef0f7d14e9cc528064
parentc17808562e4ff3bcc3c3755a6b5ffbf86b8624ad
glsl: Fix memory leak with known glsl_type instances

When looking up known glsl_type instances in the various hash tables, we
end up leaking the key instances used for the lookup, as the glsl_type
constructor allocates memory on the global mem_ctx. This patch changes
glsl_type to manage its own memory, which fixes the leak and also allows
getting rid of the global mem_ctx and its mutex.

v2: remove lambda usage (Tapani)
    (+keep ASSERT_BITFIELD_SIZE, modify dummy ctor to initialize mem_ctx)

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104884
Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Simon Hausmann <simon.hausmann@qt.io>
Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/compiler/glsl_types.cpp
src/compiler/glsl_types.h