Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 46 additions & 3 deletions cfg/gtk.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -336,13 +336,13 @@
<define name="G_FILE_ATTRIBUTE_TRASH_ORIG_PATH" value="&quot;trash::orig-path&quot;"/>
<define name="G_FILE_ATTRIBUTE_TRASH_DELETION_DATE" value="&quot;trash::deletion-date&quot;"/>
<define name="G_FILE_ATTRIBUTE_RECENT_MODIFIED" value="&quot;recent::modified&quot;"/>
<memory>
<resource>
<alloc init="true" no-fail="true">g_thread_new</alloc>
<alloc init="true" no-fail="false">g_thread_try_new</alloc>
<use>g_thread_ref</use>
<dealloc>g_thread_unref</dealloc>
<dealloc>g_thread_join</dealloc>
</memory>
</resource>
<memory>
<alloc init="true" no-fail="true">g_variant_iter_copy</alloc>
<alloc init="true" no-fail="true">g_variant_iter_new</alloc>
Expand Down Expand Up @@ -8387,9 +8387,52 @@
<leak-ignore/>
<noreturn>false</noreturn>
</function>
<!-- GThread * g_thread_new (const gchar *name, GThreadFunc func, gpointer data); -->
<function name="g_thread_new">
<noreturn>false</noreturn>
<returnValue type="GThread *"/>
<use-retval/>
<arg nr="1" direction="in">
<not-uninit/>
</arg>
<arg nr="2" direction="in">
<not-null/>
<not-uninit/>
</arg>
<arg nr="3"/>
</function>
<!-- GThread * g_thread_try_new (const gchar *name, GThreadFunc func, gpointer data, GError **error); -->
<function name="g_thread_try_new">
<noreturn>false</noreturn>
<returnValue type="GThread *"/>
<use-retval/>
<arg nr="1" direction="in">
<not-uninit/>
</arg>
<arg nr="2" direction="in">
<not-null/>
<not-uninit/>
</arg>
<arg nr="3"/>
<arg nr="4" direction="out"/>
</function>
<!-- gpointer g_thread_join (GThread *thread); -->
<function name="g_thread_join">
<leak-ignore/>
<noreturn>false</noreturn>
<returnValue type="gpointer"/>
<arg nr="1">
<not-null/>
<not-uninit/>
</arg>
</function>
<!-- void g_thread_unref (GThread *thread); -->
<function name="g_thread_unref">
<noreturn>false</noreturn>
<returnValue type="void"/>
<arg nr="1">
<not-null/>
<not-uninit/>
</arg>
</function>
<function name="g_thread_pool_get_max_threads">
<leak-ignore/>
Expand Down
54 changes: 54 additions & 0 deletions test/cfg/gtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -777,3 +777,57 @@ void g_idle_add_freed_data_test(void)
// TODO cppcheck-suppress deallocuse
g_idle_add(source_func_frees_data, data);
}

static gpointer thread_func(gpointer data)
{
return data;
}

void g_thread_join_releases_thread_test(void)
{
GThread *thread = g_thread_new("test", thread_func, NULL);
g_thread_join(thread);

GThread *thread_try = g_thread_try_new("test", thread_func, NULL, NULL);
if (thread_try)
g_thread_join(thread_try);
}

// Creating a thread has side effects, so a thread that is only released is
// not unused.
void g_thread_unref_detaches_thread_test(void)
{
GThread *thread = g_thread_new("test", thread_func, NULL);
g_thread_unref(thread);
}

void g_thread_join_parameter_test(GThread *thread)
{
g_thread_join(thread);
}

// The thread function gets the data as a non-const gpointer.
void g_thread_data_test(int *data)
{
GThread *thread = g_thread_new("test", thread_func, data);
g_thread_join(thread);

GThread *thread_try = g_thread_try_new("test", thread_func, data, NULL);
if (thread_try)
g_thread_join(thread_try);
}

void g_thread_not_joined_test(void)
{
GThread *thread = g_thread_new("test", thread_func, NULL);
(void)thread;
// cppcheck-suppress resourceLeak
}

void g_thread_joined_twice_test(void)
{
GThread *thread = g_thread_new("test", thread_func, NULL);
g_thread_join(thread);
// cppcheck-suppress doubleFree
g_thread_join(thread);
}
Loading