X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fhtable%2Fhtable.c;h=cffd0619d338d8146365abd3f10e1b308ef4c4d4;hb=209a81909942a07cb334d6dcae7626a3ecde141d;hp=d3c4f9b41187a9ef0481e332d710e95e42b29bea;hpb=7623d0829a63e7f95ed6f116b7e9f2f4a023e8e7;p=ccan diff --git a/ccan/htable/htable.c b/ccan/htable/htable.c index d3c4f9b4..cffd0619 100644 --- a/ccan/htable/htable.c +++ b/ccan/htable/htable.c @@ -365,6 +365,20 @@ void htable_delval_(struct htable *ht, struct htable_iter *i) ht->deleted++; } +void *htable_pick_(const struct htable *ht, size_t seed, struct htable_iter *i) +{ + void *e; + struct htable_iter unwanted; + + if (!i) + i = &unwanted; + i->off = seed % ((size_t)1 << ht->bits); + e = htable_next(ht, i); + if (!e) + e = htable_first(ht, i); + return e; +} + struct htable *htable_check(const struct htable *ht, const char *abortstr) { void *p;