Mercurial > dovecot > original-hg > dovecot-1.2
view src/lib/env-util.c @ 8590:b9faf4db2a9f HEAD
Updated copyright notices to include year 2009.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 06 Jan 2009 09:25:38 -0500 |
parents | b1a7df02ba38 |
children | 7c12e20f1eee |
line wrap: on
line source
/* Copyright (c) 2002-2009 Dovecot authors, see the included COPYING file */ #include "lib.h" #include "env-util.h" #include <stdlib.h> static pool_t pool = NULL; void env_put(const char *env) { if (pool == NULL) { pool = pool_alloconly_create(MEMPOOL_GROWING"Environment", 2048); } if (putenv(p_strdup(pool, env)) != 0) i_fatal("putenv(%s) failed: %m", env); } void env_remove(const char *name) { unsetenv(name); } void env_clean(void) { #ifdef HAVE_CLEARENV if (clearenv() < 0) i_fatal("clearenv() failed"); #else extern char **environ; /* Try to clear the environment. a) environ = NULL crashes on OS X. b) *environ = NULL doesn't work on FreeBSD 7.0. c) environ = emptyenv doesn't work on Haiku OS d) environ = calloc() should work everywhere */ environ = calloc(1, sizeof(*environ)); #endif /* don't clear the env_pool, otherwise the environment would get corrupted if we failed to clear it. */ }