fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / gcc / newlib / libc / argz / argz_add.c
blob46e71ca371ef619d3be01901ac3bb565f00b7aae
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 <string.h>
10 #include <stdlib.h>
12 error_t
13 _DEFUN (argz_add, (argz, argz_len, str),
14 char **argz _AND
15 size_t *argz_len _AND
16 const char *str)
18 int len_to_add = 0;
19 size_t last = *argz_len;
21 if (str == NULL)
22 return 0;
24 len_to_add = strlen(str) + 1;
25 *argz_len += len_to_add;
27 if(!(*argz = (char *)realloc(*argz, *argz_len)))
28 return ENOMEM;
30 memcpy(*argz + last, str, len_to_add);
31 return 0;