gthread: Mark data allocated with g_private_set_alloc0 as leaking

This is what we already ignored with valgrind and it's something that
we should always ignore since it's leaked by design.

So do explicitly mark it as such.
This commit is contained in:
Marco Trevisan (Treviño) 2024-05-10 01:35:15 +02:00
parent c91dc83fb0
commit a04163d8ac

View File

@ -40,6 +40,7 @@
#include "config.h"
#include "glib-private.h"
#include "gthread.h"
#include "gthreadprivate.h"
@ -505,10 +506,10 @@ static GPrivate g_thread_specific_private = G_PRIVATE_INIT (g_thread_cleanup
*
* Sets the thread local variable @key to have a newly-allocated and zero-filled
* value of given @size, and returns a pointer to that memory. Allocations made
* using this API will be suppressed in valgrind: it is intended to be used for
* one-time allocations which are known to be leaked, such as those for
* per-thread initialisation data. Otherwise, this function behaves the same as
* g_private_set().
* using this API will be suppressed in valgrind and leak sanitizer: it is
* intended to be used for one-time allocations which are known to be leaked,
* such as those for per-thread initialisation data. Otherwise, this function
* behaves the same as g_private_set().
*
* Returns: (transfer full): new thread-local heap allocation of size @size
* Since: 2.60
@ -520,6 +521,7 @@ g_private_set_alloc0 (GPrivate *key,
{
gpointer allocated = g_malloc0 (size);
g_ignore_leak (allocated);
g_private_set (key, allocated);
return g_steal_pointer (&allocated);