[glib] Cleanups to debug env var handling
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Cleanups to debug env var handling
- Date: Sun, 13 Nov 2011 00:14:32 +0000 (UTC)
commit 599f254066beb3bdad1d4fb70a7afd28c45d7634
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Nov 12 19:13:44 2011 -0500
Cleanups to debug env var handling
glib/glib-init.c | 6 +++---
glib/gslice.c | 48 ++++++++++++++++++------------------------------
gobject/gtype.c | 13 +++++--------
3 files changed, 26 insertions(+), 41 deletions(-)
---
diff --git a/glib/glib-init.c b/glib/glib-init.c
index eb6d8e8..b86074b 100644
--- a/glib/glib-init.c
+++ b/glib/glib-init.c
@@ -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))
{
diff --git a/glib/gslice.c b/glib/gslice.c
index 396ce48..2687e27 100644
--- a/glib/gslice.c
+++ b/glib/gslice.c
@@ -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
diff --git a/gobject/gtype.c b/gobject/gtype.c
index 3d79f7b..a0e9106 100644
--- a/gobject/gtype.c
+++ b/gobject/gtype.c
@@ -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 */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]