Cygwin: mmap: allow remapping part of an existing anonymous mapping
[newlib-cygwin.git] / newlib / libc / argz / argz_append.c
blobde0cc82ceb5b41c26e97b3d832ef1d0f33aa4834
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_append (char **argz,
15 size_t *argz_len,
16 const char *buf,
17 size_t buf_len)
19 if (buf_len)
21 size_t last = *argz_len;
23 *argz_len += buf_len;
25 if(!(*argz = (char *)realloc(*argz, *argz_len)))
26 return ENOMEM;
28 memcpy(*argz + last, buf, buf_len);
30 return 0;