+/* Iterate over each key/value pair and execut 'fn' with key and value as
+ arguments */
+STON_FUNC
+void ston_dht_iterate
+( struct ston_dht_t* ht,
+ void (*fn)(void*,void*,void*),
+ void* user_data
+)
+{ ht->ht_iter = fn;
+ ht->ht_user_data = user_data;
+ ston_dht_iterate_r(ht,(void**)ht->bucket_root);
+}
+
+/* Recursively iterate through the given bucket belonging to hashtable ht */
+STON_FUNC_STATIC
+STON_FUNC_NOINLINE
+void ston_dht_iterate_r
+( struct ston_dht_t* ht,
+ void* bucket
+)
+{ uint8_t* row = (uint8_t*)bucket;
+ uint8_t* row_max = (row + (ht->rowsize * 0x100));
+ while (row < row_max)
+ { if (*(void**)row != NULL)
+ ston_dht_iterate_r(ht, *(void**)row);
+ row += sizeof(void*);
+ ht->ht_iter((void*)row, (void*)(row + ht->header.key_bytes),ht->ht_user_data);
+ row += ht->header.key_bytes + ht->header.val_bytes;
+ }
+}