From: Ben Gras Date: Fri, 8 Jul 2011 12:24:57 +0000 (+0200) Subject: nbsd libc: global constructors run sanity check X-Git-Tag: v3.2.0~485 X-Git-Url: http://zhaoyanbai.com/repos/doc/roff.7.html?a=commitdiff_plain;h=cf7f7d0ef14dc059b0497ec129f3715e4e0e7176;p=minix.git nbsd libc: global constructors run sanity check --- diff --git a/lib/nbsd_libc/stdlib/_env.c b/lib/nbsd_libc/stdlib/_env.c index 93a6ab6e8..a84c36a87 100644 --- a/lib/nbsd_libc/stdlib/_env.c +++ b/lib/nbsd_libc/stdlib/_env.c @@ -29,6 +29,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ +static int inited = 0; + #include #if defined(LIBC_SCCS) && !defined(lint) __RCSID("$NetBSD: _env.c,v 1.5 2010/11/17 13:25:53 tron Exp $"); @@ -157,6 +159,7 @@ __freeenvvar(char *envvar) env_node_t *node; _DIAGASSERT(envvar != NULL); + assert(inited); node = rb_tree_find_node(&env_tree, envvar); if (node != NULL) { rb_tree_remove_node(&env_tree, node); @@ -173,6 +176,7 @@ __allocenvvar(size_t length) { env_node_t *node; + assert(inited); node = malloc(sizeof(*node) + length); if (node != NULL) { node->length = length; @@ -194,6 +198,8 @@ __canoverwriteenvvar(char *envvar, size_t length) { env_node_t *node; + assert(inited); + _DIAGASSERT(envvar != NULL); node = rb_tree_find_node(&env_tree, envvar); @@ -208,6 +214,7 @@ __scrubenv(void) size_t num_entries; env_node_t *node, *next; + assert(inited); while (++marker == 0); /* Mark all nodes which are currently used. */ @@ -401,5 +408,7 @@ __unlockenv(void) void __libc_env_init(void) { + assert(!inited); rb_tree_init(&env_tree, &env_tree_ops); + inited = 1; }