summaryrefslogtreecommitdiff
path: root/glib/gslice.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2011-10-15 16:13:08 -0400
committerMatthias Clasen <mclasen@redhat.com>2011-10-15 16:13:08 -0400
commit7a9987d35d568707df2c7c12e851623b46e9e63d (patch)
tree5b1ed585fbe72dd2cb1b0e6ba9383a98f4d85a62 /glib/gslice.c
parent409d93148f2d95c2966f75fe0901edd1e06c99a9 (diff)
downloadglib-7a9987d35d568707df2c7c12e851623b46e9e63d.tar.gz
Move environment-related functions into their own files
gutils.[hc] is a bit of a grab bag, so lets start cleaning things up by moving all the environment-related functions into separate genviron.[hc] files. The private _g_getenv_nomalloc has been moved to its sole caller.
Diffstat (limited to 'glib/gslice.c')
-rw-r--r--glib/gslice.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/glib/gslice.c b/glib/gslice.c
index 2cd44f5d8..f89a3cdb4 100644
--- a/glib/gslice.c
+++ b/glib/gslice.c
@@ -278,12 +278,30 @@ 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 = _g_getenv_nomalloc ("G_SLICE", buffer);
+ const gchar *val = getenv_nomalloc ("G_SLICE", buffer);
const GDebugKey keys[] = {
{ "always-malloc", 1 << 0 },
{ "debug-blocks", 1 << 1 },