svn commit: r204323 - user/luigi/ipfw3-head/sys/netinet/ipfw
Luigi Rizzo
luigi at FreeBSD.org
Thu Feb 25 16:39:29 UTC 2010
Author: luigi
Date: Thu Feb 25 16:39:28 2010
New Revision: 204323
URL: http://svn.freebsd.org/changeset/base/204323
Log:
add function dn_ht_scan_bucket()
Modified:
user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.c
Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.c Thu Feb 25 16:14:07 2010 (r204322)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.c Thu Feb 25 16:39:28 2010 (r204323)
@@ -471,3 +471,39 @@ dn_ht_scan(struct dn_ht *ht, int (*fn)(v
}
return found;
}
+
+/*
+ * Similar to dn_ht_scan(), except thah the scan is performed only
+ * in the bucket 'bucket'. The function returns a correct bucket number if
+ * the original is invalid
+ */
+int
+dn_ht_scan_bucket(struct dn_ht *ht, int *bucket, int (*fn)(void *, void *),
+ void *arg)
+{
+ int i, ret, found = 0;
+ void **curp, *cur, *next;
+
+ if (ht == NULL || fn == NULL)
+ return 0;
+ if (*bucket >= ht->buckets)
+ *bucket = 0;
+ i = *bucket;
+
+ curp = &ht->ht[i];
+ while ( (cur = *curp) != NULL) {
+ next = *(void **)((char *)cur + ht->ofs);
+ ret = fn(cur, arg);
+ if (ret & DNHT_SCAN_DEL) {
+ found++;
+ ht->entries--;
+ *curp = next;
+ } else {
+ curp = (void **)((char *)cur + ht->ofs);
+ }
+ if (ret & DNHT_SCAN_END)
+ return found;
+ }
+ return found;
+}
+
More information about the svn-src-user
mailing list