Cygwin: mmap: allow remapping part of an existing anonymous mapping
[newlib-cygwin.git] / newlib / libc / argz / argz_extract.c
blobe97b76905d262eedd04c54436281a39d2533e7f1
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 <stddef.h>
8 #include <argz.h>
9 #include <sys/types.h>
11 void
12 argz_extract (char *argz,
13 size_t argz_len,
14 char **argv)
16 size_t i = 0;
17 int j = 0;
18 const size_t count = argz_count(argz, argz_len);
20 if (argz_len > 1)
21 for (i = argz_len - 2; i > 0; i--)
23 if (argz[i] == '\0')
25 j++;
26 argv[count - j] = &argz[i + 1];
29 argv[0] = &argz[0];
30 argv[count] = NULL;