fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / gcc / newlib / libc / argz / envz_remove.c
blob1882297f0ecd2e9725cb9a23b1022ca01cfb3aeb
1 /* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved.
3 * Permission to use, copy, modify, and distribute this software
4 * is freely granted, provided that this notice is preserved.
5 */
7 #include <errno.h>
8 #include <sys/types.h>
9 #include <string.h>
10 #include <stdlib.h>
11 #include <argz.h>
12 #include <envz.h>
14 void
15 _DEFUN (envz_remove, (envz, envz_len, name),
16 char **envz _AND
17 size_t *envz_len _AND
18 const char *name)
20 char *entry = NULL;
21 int len = 0;
22 entry = envz_entry (*envz, *envz_len, name);
24 if (entry)
26 len = strlen(entry) + 1;
28 /* Not the last entry. */
29 if (*envz + *envz_len != entry + len - 1)
31 memmove(entry, entry + len, *envz + *envz_len - entry - len);
34 *envz = (char *)realloc(*envz, *envz_len - len);
35 *envz_len -= len;