mesa: call atexit() only as needed
authorEmil Velikov <emil.velikov@collabora.com>
Mon, 6 Nov 2017 16:02:32 +0000 (16:02 +0000)
committerEmil Velikov <emil.l.velikov@gmail.com>
Thu, 16 Nov 2017 14:08:03 +0000 (14:08 +0000)
If the extra_extensions string is empty there's no need to call
atexit() - there's nothing to free.

v2: Rebase

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Brian Paul <brianp@vmware.com> (v1)
src/mesa/main/extensions.c

index 7483b8f24967c9ea7a2651638c24137dfd831a11..be3970c639302c0c821b4d8aec014fd93a79b847 100644 (file)
@@ -245,8 +245,6 @@ _mesa_one_time_init_extension_overrides(void)
    int len;
    size_t offset;
 
-   atexit(free_unknown_extensions_strings);
-
    memset(&_mesa_extension_override_enables, 0, sizeof(struct gl_extensions));
    memset(&_mesa_extension_override_disables, 0, sizeof(struct gl_extensions));
 
@@ -305,9 +303,9 @@ _mesa_one_time_init_extension_overrides(void)
    len = strlen(extra_extensions);
    if (len == 0) {
       free(extra_extensions);
-      extra_extensions = NULL;
    } else if (extra_extensions[len - 1] == ' ') {
       extra_extensions[len - 1] = '\0';
+      atexit(free_unknown_extensions_strings);
    }
 }