mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-14 00:06:24 +01:00
autocleanups: Add GString type
https://bugzilla.gnome.org/show_bug.cgi?id=754831
This commit is contained in:
parent
4025b5a54f
commit
d19411a76f
@ -29,8 +29,15 @@ g_autoptr_cleanup_generic_gfree (void *p)
|
||||
g_free (*pp);
|
||||
}
|
||||
|
||||
static inline void
|
||||
g_autoptr_cleanup_gstring_free (GString *string)
|
||||
{
|
||||
if (string)
|
||||
g_string_free (string, TRUE);
|
||||
}
|
||||
|
||||
/* If adding a cleanup here, please also add a test case to
|
||||
* glib/glib/autoptr.c
|
||||
* glib/tests/autoptr.c
|
||||
*/
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GAsyncQueue, g_async_queue_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GBookmarkFile, g_bookmark_file_free)
|
||||
@ -64,6 +71,7 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMatchInfo, g_match_info_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GScanner, g_scanner_destroy)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSequence, g_sequence_free)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSList, g_slist_free)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GString, g_autoptr_cleanup_gstring_free)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GStringChunk, g_string_chunk_free)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GThread, g_thread_unref)
|
||||
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GMutex, g_mutex_clear)
|
||||
|
@ -276,6 +276,13 @@ test_g_slist (void)
|
||||
g_assert (nonempty_val != NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
test_g_string (void)
|
||||
{
|
||||
g_autoptr(GString) val = g_string_new ("");
|
||||
g_assert (val != NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
test_g_string_chunk (void)
|
||||
{
|
||||
@ -428,6 +435,7 @@ main (int argc, gchar *argv[])
|
||||
g_test_add_func ("/autoptr/g_scanner", test_g_scanner);
|
||||
g_test_add_func ("/autoptr/g_sequence", test_g_sequence);
|
||||
g_test_add_func ("/autoptr/g_slist", test_g_slist);
|
||||
g_test_add_func ("/autoptr/g_string", test_g_string);
|
||||
g_test_add_func ("/autoptr/g_string_chunk", test_g_string_chunk);
|
||||
g_test_add_func ("/autoptr/g_thread", test_g_thread);
|
||||
g_test_add_func ("/autoptr/g_mutex", test_g_mutex);
|
||||
|
Loading…
Reference in New Issue
Block a user