mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-26 12:12:10 +01:00
gio/tests: simplify enum to string in memory-monitor
Also results in more robust handling, since it can get a NULL eclass. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
parent
b26c463039
commit
06160facf3
@ -18,21 +18,6 @@
|
|||||||
|
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
|
|
||||||
static const char *
|
|
||||||
get_level_string (GMemoryMonitorWarningLevel level)
|
|
||||||
{
|
|
||||||
GEnumClass *eclass;
|
|
||||||
GEnumValue *value;
|
|
||||||
|
|
||||||
eclass = G_ENUM_CLASS (g_type_class_peek (G_TYPE_MEMORY_MONITOR_WARNING_LEVEL));
|
|
||||||
value = g_enum_get_value (eclass, level);
|
|
||||||
|
|
||||||
if (value == NULL)
|
|
||||||
return "unknown";
|
|
||||||
|
|
||||||
return value->value_nick;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_dup_default (void)
|
test_dup_default (void)
|
||||||
{
|
{
|
||||||
@ -47,10 +32,9 @@ static void
|
|||||||
warning_cb (GMemoryMonitor *m,
|
warning_cb (GMemoryMonitor *m,
|
||||||
GMemoryMonitorWarningLevel level)
|
GMemoryMonitorWarningLevel level)
|
||||||
{
|
{
|
||||||
const char *str;
|
char *str = g_enum_to_string (G_TYPE_MEMORY_MONITOR_WARNING_LEVEL, level);
|
||||||
|
|
||||||
str = get_level_string (level);
|
|
||||||
g_debug ("Warning level: %s (%d)", str , level);
|
g_debug ("Warning level: %s (%d)", str , level);
|
||||||
|
g_free (str);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user