Cygwin: mmap: allow remapping part of an existing anonymous mapping
[newlib-cygwin.git] / newlib / libc / argz / argz_add_sep.c
blobf2964e672d4da3944ab0bea93c5753d73a8be298
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 <stdlib.h>
10 #include <string.h>
11 #include <argz.h>
13 error_t
14 argz_add_sep (char **argz,
15 size_t *argz_len,
16 const char *str,
17 int sep)
19 char *str_argz = 0;
20 size_t str_argz_len = 0;
21 size_t last = *argz_len;
23 argz_create_sep (str, sep, &str_argz, &str_argz_len);
25 if (str_argz_len)
27 *argz_len += str_argz_len;
29 if(!(*argz = (char *)realloc(*argz, *argz_len)))
30 return ENOMEM;
32 memcpy(*argz + last, str_argz, str_argz_len);
34 return 0;