src/server/util/pblock.c

changeset 667
1f0f014c0121
parent 556
b036ccad4b49
equal deleted inserted replaced
666:c99e0b352e36 667:1f0f014c0121
1421 memcpy(pp->value, value, valuelen + 1); 1421 memcpy(pp->value, value, valuelen + 1);
1422 } else { 1422 } else {
1423 pblock_kvinsert(key, value, valuelen, pb); 1423 pblock_kvinsert(key, value, valuelen, pb);
1424 } 1424 }
1425 } 1425 }
1426
1427
1428 /* ------------------------ UCX Iterator for pblock ------------------------ */
1429
1430 static bool pblock_iterator_valid(const void *it) {
1431 const CxIterator *i = it;
1432 return i->elem_handle != NULL;
1433 }
1434
1435
1436 static void* pblock_iterator_current(const void *it) {
1437 const CxIterator *i = it;
1438 return i->elem_handle;
1439 }
1440
1441 static void pblock_iterator_next(void *it) {
1442 CxIterator *i = it;
1443 pblock *p = i->src_handle;
1444 while(i->index < p->hsize) {
1445 pb_entry *entry = i->elem_handle;
1446 if(entry) {
1447 entry = entry->next;
1448 } else {
1449 entry = p->ht[i->index];
1450 }
1451
1452 if(entry) {
1453 i->elem_handle = entry;
1454 return;
1455 }
1456 i->elem_handle = NULL;
1457 i->index++;
1458 }
1459 }
1460
1461
1462 NSAPI_PUBLIC CxIterator pblock_iterator(pblock *pb) {
1463 CxIterator i;
1464 memset(&i, 0, sizeof(CxIterator));
1465 i.base.valid = pblock_iterator_valid;
1466 i.base.current = pblock_iterator_current;
1467 i.base.next = pblock_iterator_next;
1468 i.src_handle = pb;
1469 pblock_iterator_next(&i);
1470 return i;
1471 }
1472

mercurial