source: trunk/libs/newlib/src/newlib/libc/argz/envz_remove.c @ 444

Last change on this file since 444 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 803 bytes
Line 
1/* Copyright (C) 2002 by  Red Hat, Incorporated. All rights reserved.
2 *
3 * Permission to use, copy, modify, and distribute this software
4 * is freely granted, provided that this notice is preserved.
5 */
6
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>
13
14void
15envz_remove (char **envz,
16       size_t *envz_len,
17       const char *name)
18{
19  char *entry = NULL;
20  int len = 0;
21  entry = envz_entry (*envz, *envz_len, name);
22
23  if (entry)
24    {
25      len = strlen(entry) + 1;
26
27      /* Not the last entry. */
28      if (*envz + *envz_len != entry + len - 1)
29        {
30          memmove(entry, entry + len, *envz + *envz_len - entry - len);
31        }
32
33      *envz = (char *)realloc(*envz, *envz_len - len);
34      *envz_len -= len;
35    }
36}
Note: See TracBrowser for help on using the repository browser.