Cygwin: mmap: allow remapping part of an existing anonymous mapping
[newlib-cygwin.git] / newlib / libc / argz / argz_delete.c
blobaa1fe4c7533000823945ebf449ed70c8297c46a2
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 <argz.h>
8 #include <errno.h>
9 #include <sys/types.h>
10 #include <string.h>
11 #include <stdlib.h>
13 error_t
14 argz_delete (char **argz,
15 size_t *argz_len,
16 char *entry)
18 int len = 0;
19 char *moveto = entry;
21 if (entry)
23 len = strlen(entry) + 1;
24 entry += len;
26 memmove(moveto, entry, *argz + *argz_len - entry);
28 *argz_len -= len;
30 if(!(*argz = (char *)realloc(*argz, *argz_len)))
31 return ENOMEM;
33 if (*argz_len <= 0)
35 free(*argz);
36 *argz = NULL;
39 return 0;