Tue Jul 2 23:45:14 1996 Ulrich Drepper <drepper@cygnus.com>
[glibc/history.git] / string / argz-delete.c
blob729b1b8371496c3c1807b2c9b8144fa1a08441cb
1 /* Routines for dealing with '\0' separated arg vectors.
3 Copyright (C) 1995, 1996 Free Software Foundation, Inc.
5 Written by Miles Bader <miles@gnu.ai.mit.edu>
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2, or (at
10 your option) any later version.
12 This program is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
21 #include <argz.h>
22 #include <string.h>
23 #include <stdlib.h>
25 /* Delete ENTRY from ARGZ & ARGZ_LEN, if any. */
26 void
27 argz_delete (char **argz, size_t *argz_len, char *entry)
29 if (entry)
30 /* Get rid of the old value for NAME. */
32 size_t entry_len = strlen (entry) + 1;
33 *argz_len -= entry_len;
34 memcpy (entry, entry + entry_len, *argz_len - (entry - *argz));
35 if (*argz_len == 0)
37 free (*argz);
38 *argz = 0;