Revision f2b07f35 qdict.c
b/qdict.c | ||
---|---|---|
345 | 345 |
} |
346 | 346 |
} |
347 | 347 |
|
348 |
static QDictEntry *qdict_next_entry(const QDict *qdict, int first_bucket) |
|
349 |
{ |
|
350 |
int i; |
|
351 |
|
|
352 |
for (i = first_bucket; i < QDICT_BUCKET_MAX; i++) { |
|
353 |
if (!QLIST_EMPTY(&qdict->table[i])) { |
|
354 |
return QLIST_FIRST(&qdict->table[i]); |
|
355 |
} |
|
356 |
} |
|
357 |
|
|
358 |
return NULL; |
|
359 |
} |
|
360 |
|
|
361 |
/** |
|
362 |
* qdict_first(): Return first qdict entry for iteration. |
|
363 |
*/ |
|
364 |
const QDictEntry *qdict_first(const QDict *qdict) |
|
365 |
{ |
|
366 |
return qdict_next_entry(qdict, 0); |
|
367 |
} |
|
368 |
|
|
369 |
/** |
|
370 |
* qdict_next(): Return next qdict entry in an iteration. |
|
371 |
*/ |
|
372 |
const QDictEntry *qdict_next(const QDict *qdict, const QDictEntry *entry) |
|
373 |
{ |
|
374 |
QDictEntry *ret; |
|
375 |
|
|
376 |
ret = QLIST_NEXT(entry, next); |
|
377 |
if (!ret) { |
|
378 |
unsigned int bucket = tdb_hash(entry->key) % QDICT_BUCKET_MAX; |
|
379 |
ret = qdict_next_entry(qdict, bucket + 1); |
|
380 |
} |
|
381 |
|
|
382 |
return ret; |
|
383 |
} |
|
384 |
|
|
348 | 385 |
/** |
349 | 386 |
* qentry_destroy(): Free all the memory allocated by a QDictEntry |
350 | 387 |
*/ |
Also available in: Unified diff