OSDN Git Service

mesa/main: free locale at exit
authorErik Faye-Lund <kusmabite@gmail.com>
Sun, 28 Jun 2015 12:51:09 +0000 (14:51 +0200)
committerMatt Turner <mattst88@gmail.com>
Mon, 29 Jun 2015 16:06:40 +0000 (09:06 -0700)
In order to save a small leak if mesa is continously loaded and
unloaded, let's free the locale when the shared object is unloaded.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
src/mesa/main/context.c
src/util/strtod.c
src/util/strtod.h

index e68de68..fdef412 100644 (file)
@@ -346,6 +346,16 @@ _mesa_destroy_visual( struct gl_config *vis )
 mtx_t OneTimeLock = _MTX_INITIALIZER_NP;
 
 
+/**
+ * Calls all the various one-time-fini functions in Mesa
+ */
+
+static void
+one_time_fini(void)
+{
+   _mesa_destroy_shader_compiler();
+   _mesa_locale_fini();
+}
 
 /**
  * Calls all the various one-time-init functions in Mesa.
@@ -385,7 +395,7 @@ one_time_init( struct gl_context *ctx )
          _mesa_ubyte_to_float_color_tab[i] = (float) i / 255.0F;
       }
 
-      atexit(_mesa_destroy_shader_compiler);
+      atexit(one_time_fini);
 
 #if defined(DEBUG) && defined(__DATE__) && defined(__TIME__)
       if (MESA_VERBOSE != 0) {
index a4a60e0..ea7d395 100644 (file)
@@ -45,6 +45,14 @@ _mesa_locale_init(void)
 #endif
 }
 
+void
+_mesa_locale_fini(void)
+{
+#if defined(_GNU_SOURCE) && defined(HAVE_XLOCALE_H)
+   freelocale(loc);
+#endif
+}
+
 /**
  * Wrapper around strtod which uses the "C" locale so the decimal
  * point is always '.'
index b7e2beb..60e15cf 100644 (file)
@@ -34,6 +34,9 @@ extern "C" {
 extern void
 _mesa_locale_init(void);
 
+extern void
+_mesa_locale_fini(void);
+
 extern double
 _mesa_strtod(const char *s, char **end);