mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-26 05:56:14 +01:00
Cleanups to debug env var handling
This commit is contained in:
parent
943a18b564
commit
599f254066
@ -108,10 +108,10 @@ g_parse_debug_string (const gchar *string,
|
||||
if (!strcasecmp (string, "help"))
|
||||
{
|
||||
/* using stdio directly for the reason stated above */
|
||||
fprintf (stderr, "Supported debug values: ");
|
||||
fprintf (stderr, "Supported debug values:");
|
||||
for (i = 0; i < nkeys; i++)
|
||||
fprintf (stderr, " %s", keys[i].key);
|
||||
fprintf (stderr, "\n");
|
||||
fprintf (stderr, " all help\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -123,7 +123,7 @@ g_parse_debug_string (const gchar *string,
|
||||
{
|
||||
q = strpbrk (p, ":;, \t");
|
||||
if (!q)
|
||||
q = p + strlen(p);
|
||||
q = p + strlen (p);
|
||||
|
||||
if (debug_key_matches ("all", p, q - p))
|
||||
{
|
||||
|
@ -279,40 +279,28 @@ g_slice_get_config_state (GSliceConfig ckey,
|
||||
}
|
||||
}
|
||||
|
||||
static const gchar *
|
||||
getenv_nomalloc (const gchar *variable,
|
||||
gchar buffer[1024])
|
||||
{
|
||||
const gchar *retval = getenv (variable);
|
||||
if (retval && retval[0])
|
||||
{
|
||||
gint l = strlen (retval);
|
||||
if (l < 1024)
|
||||
{
|
||||
strncpy (buffer, retval, l);
|
||||
buffer[l] = 0;
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
slice_config_init (SliceConfig *config)
|
||||
{
|
||||
/* don't use g_malloc/g_message here */
|
||||
gchar buffer[1024];
|
||||
const gchar *val = getenv_nomalloc ("G_SLICE", buffer);
|
||||
const GDebugKey keys[] = {
|
||||
{ "always-malloc", 1 << 0 },
|
||||
{ "debug-blocks", 1 << 1 },
|
||||
};
|
||||
gint flags = !val ? 0 : g_parse_debug_string (val, keys, G_N_ELEMENTS (keys));
|
||||
const gchar *val;
|
||||
|
||||
*config = slice_config;
|
||||
if (flags & (1 << 0)) /* always-malloc */
|
||||
config->always_malloc = TRUE;
|
||||
if (flags & (1 << 1)) /* debug-blocks */
|
||||
config->debug_blocks = TRUE;
|
||||
|
||||
val = getenv ("G_SLICE");
|
||||
if (val != NULL)
|
||||
{
|
||||
gint flags;
|
||||
const GDebugKey keys[] = {
|
||||
{ "always-malloc", 1 << 0 },
|
||||
{ "debug-blocks", 1 << 1 },
|
||||
};
|
||||
|
||||
flags = g_parse_debug_string (val, keys, G_N_ELEMENTS (keys));
|
||||
if (flags & (1 << 0))
|
||||
config->always_malloc = TRUE;
|
||||
if (flags & (1 << 1))
|
||||
config->debug_blocks = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -4290,15 +4290,12 @@ g_type_init_with_debug_flags (GTypeDebugFlags debug_flags)
|
||||
env_string = g_getenv ("GOBJECT_DEBUG");
|
||||
if (env_string != NULL)
|
||||
{
|
||||
static GDebugKey debug_keys[] = {
|
||||
{ "objects", G_TYPE_DEBUG_OBJECTS },
|
||||
{ "signals", G_TYPE_DEBUG_SIGNALS },
|
||||
GDebugKey debug_keys[] = {
|
||||
{ "objects", G_TYPE_DEBUG_OBJECTS },
|
||||
{ "signals", G_TYPE_DEBUG_SIGNALS },
|
||||
};
|
||||
|
||||
_g_type_debug_flags |= g_parse_debug_string (env_string,
|
||||
debug_keys,
|
||||
sizeof (debug_keys) / sizeof (debug_keys[0]));
|
||||
env_string = NULL;
|
||||
|
||||
_g_type_debug_flags |= g_parse_debug_string (env_string, debug_keys, G_N_ELEMENTS (debug_keys));
|
||||
}
|
||||
|
||||
/* quarks */
|
||||
|
Loading…
Reference in New Issue
Block a user