mesa: free debug messages when destroying the debug state
authorTimothy Arceri <tarceri@itsqueeze.com>
Fri, 13 Apr 2018 05:23:57 +0000 (15:23 +1000)
committerTimothy Arceri <tarceri@itsqueeze.com>
Fri, 13 Apr 2018 12:20:48 +0000 (22:20 +1000)
Fixes: 04a8baad3721 "mesa: refactor _mesa_PopDebugGroup and _mesa_free_errors_data"
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98281

src/mesa/main/debug_output.c

index 3d6cc18c2fabb0d54cc37cee537b8d2032ff72ec..b2a4fb5c2dae580926100ec5a5c7bd8d273872cc 100644 (file)
@@ -500,6 +500,28 @@ debug_clear_group(struct gl_debug_state *debug)
    debug->Groups[gstack] = NULL;
 }
 
+/**
+ * Delete the oldest debug messages out of the log.
+ */
+static void
+debug_delete_messages(struct gl_debug_state *debug, int count)
+{
+   struct gl_debug_log *log = &debug->Log;
+
+   if (count > log->NumMessages)
+      count = log->NumMessages;
+
+   while (count--) {
+      struct gl_debug_message *msg = &log->Messages[log->NextMessage];
+
+      debug_message_clear(msg);
+
+      log->NumMessages--;
+      log->NextMessage++;
+      log->NextMessage %= MAX_DEBUG_LOGGED_MESSAGES;
+   }
+}
+
 /**
  * Loop through debug group stack tearing down states for
  * filtering debug messages.  Then free debug output state.
@@ -513,6 +535,7 @@ debug_destroy(struct gl_debug_state *debug)
    }
 
    debug_clear_group(debug);
+   debug_delete_messages(debug, debug->Log.NumMessages);
    free(debug);
 }
 
@@ -647,28 +670,6 @@ debug_fetch_message(const struct gl_debug_state *debug)
    return (log->NumMessages) ? &log->Messages[log->NextMessage] : NULL;
 }
 
-/**
- * Delete the oldest debug messages out of the log.
- */
-static void
-debug_delete_messages(struct gl_debug_state *debug, int count)
-{
-   struct gl_debug_log *log = &debug->Log;
-
-   if (count > log->NumMessages)
-      count = log->NumMessages;
-
-   while (count--) {
-      struct gl_debug_message *msg = &log->Messages[log->NextMessage];
-
-      debug_message_clear(msg);
-
-      log->NumMessages--;
-      log->NextMessage++;
-      log->NextMessage %= MAX_DEBUG_LOGGED_MESSAGES;
-   }
-}
-
 static struct gl_debug_message *
 debug_get_group_message(struct gl_debug_state *debug)
 {