From 02f5d8f817cf9629b1ed485751bff2b9991f0b92 Mon Sep 17 00:00:00 2001 From: "Angelos D. Keromytis" Date: Tue, 4 Jan 2000 14:23:44 +0000 Subject: Add rmoption/rmoptions; useful for people who want a slightly modified version of GENERIC. --- usr.sbin/config/hash.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'usr.sbin/config/hash.c') diff --git a/usr.sbin/config/hash.c b/usr.sbin/config/hash.c index 9110386046d..735213d0dc8 100644 --- a/usr.sbin/config/hash.c +++ b/usr.sbin/config/hash.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hash.c,v 1.6 1997/08/07 10:36:57 deraadt Exp $ */ +/* $OpenBSD: hash.c,v 1.7 2000/01/04 14:23:43 angelos Exp $ */ /* $NetBSD: hash.c,v 1.4 1996/11/07 22:59:43 gwr Exp $ */ /* @@ -249,6 +249,39 @@ ht_new() return (ht); } +/* + * Remove. + */ +int +ht_remove(ht, nam) + register struct hashtab *ht; + register const char *nam; +{ + register struct hashent *hp, *thp; + register u_int h; + + h = hash(nam); + hp = ht->ht_tab[h & ht->ht_mask]; + while (hp && hp->h_name == nam) { + ht->ht_tab[h & ht->ht_mask] = hp->h_next; + /* XXX Free hp ? */ + hp = ht->ht_tab[h & ht->ht_mask]; + } + + if ((hp = ht->ht_tab[h & ht->ht_mask]) == NULL) + return (0); + + for (thp = hp->h_next; thp != NULL; thp = hp->h_next) { + if (thp->h_name == nam) { + hp->h_next = thp->h_next; + /* XXX Free hp ? */ + } else + hp = thp; + } + + return (0); +} + /* * Insert and/or replace. */ -- cgit v1.2.3