On 03/06/16 14:01, Emilio G. Cota wrote:
> On Sun, May 29, 2016 at 22:52:27 +0300, Sergey Fedorov wrote:
>>> +/*
>>> + * Find the last valid entry in @head, and swap it with @orig[pos], which
>>> has
>>> + * just been invalidated.
>>> + */
>>> +static inline void qht_bucket_fill_hole(struct qht_bucket *orig, int pos)
>>> +{
>>> + struct qht_bucket *b = orig;
>>> + struct qht_bucket *prev = NULL;
>>> + int i;
>>> +
>>> + if (qht_entry_is_last(orig, pos)) {
>>> + orig->hashes[pos] = 0;
>>> + atomic_set(&orig->pointers[pos], NULL);
>>> + return;
>>> + }
>>> + do {
>>> + for (i = 0; i < QHT_BUCKET_ENTRIES; i++) {
>>> + if (b->pointers[i]) {
>>> + continue;
>>> + }
>>> + if (i > 0) {
>>> + return qht_entry_move(orig, pos, b, i - 1);
>>> + }
>>> + qht_debug_assert(prev);
>> 'prev' can be NULL if this is the first iteration.
> How can prev be NULL here and that not be a bug? NULL here would
> mean there was a hole before orig[pos]. Or orig[pos] was
> NULL, which is also a bug.
Yeah, you're right.
Kind regards,
Sergey