[Mesa-dev] [PATCH v2 6/7] mesa/main: free locale at exit
Matt Turner
mattst88 at gmail.com
Thu Jun 25 15:36:20 PDT 2015
On Thu, Jun 25, 2015 at 2:05 PM, Erik Faye-Lund <kusmabite at gmail.com> wrote:
> 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 at gmail.com>
> ---
> src/mesa/main/context.c | 12 +++++++++++-
> src/util/strtod.c | 8 ++++++++
> src/util/strtod.h | 3 +++
> 3 files changed, 22 insertions(+), 1 deletion(-)
>
> diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
> index e68de68..dee1fa8 100644
> --- a/src/mesa/main/context.c
> +++ b/src/mesa/main/context.c
> @@ -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()
> +{
> + _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) {
> diff --git a/src/util/strtod.c b/src/util/strtod.c
> index e5e6f76..5c36b05 100644
> --- a/src/util/strtod.c
> +++ b/src/util/strtod.c
> @@ -46,6 +46,14 @@ _mesa_locale_init(void)
> #endif
> }
>
> +void
> +_mesa_locale_fini(void)
> +{
> +#if defined(_GNU_SOURCE) && defined(HAVE_XLOCALE_H)
_GNU_SOURCE isn't a macro that you're supposed to check if it's
defined -- you're supposed to define it if you want GNU extensions.
We're misusing it elsewhere, but it would be cool if we could do this
right.
The man page of freelocale says
Since glibc 2.10:
_XOPEN_SOURCE >= 700
Before glibc 2.10:
_GNU_SOURCE
(same for newlocale() used in
glibc-2.10 is more than 6 years old. I'd be happy to use only _XOPEN_SOURCE.
I'd be fine with fixing this in a follow up.
> + freelocale(loc);
> +#endif
More information about the mesa-dev
mailing list