fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / gcc / newlib / libc / argz / argz_delete.c
blob237128c88dc6e7586433103e32ad44ce146da3b9
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_delete, (argz, argz_len, entry),
14 char **argz _AND
15 size_t *argz_len _AND
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;