Returns a quicklist iterator 'iter'. After the initialization every * call to quicklistNext() will return the next element of the quicklist. */
| 1070 | /* Returns a quicklist iterator 'iter'. After the initialization every |
| 1071 | * call to quicklistNext() will return the next element of the quicklist. */ |
| 1072 | quicklistIter *quicklistGetIterator(const quicklist *quicklist, int direction) { |
| 1073 | quicklistIter *iter; |
| 1074 | |
| 1075 | iter = zmalloc(sizeof(*iter)); |
| 1076 | |
| 1077 | if (direction == AL_START_HEAD) { |
| 1078 | iter->current = quicklist->head; |
| 1079 | iter->offset = 0; |
| 1080 | } else if (direction == AL_START_TAIL) { |
| 1081 | iter->current = quicklist->tail; |
| 1082 | iter->offset = -1; |
| 1083 | } |
| 1084 | |
| 1085 | iter->direction = direction; |
| 1086 | iter->quicklist = quicklist; |
| 1087 | |
| 1088 | iter->zi = NULL; |
| 1089 | |
| 1090 | return iter; |
| 1091 | } |
| 1092 | |
| 1093 | /* Initialize an iterator at a specific offset 'idx' and make the iterator |
| 1094 | * return nodes in 'direction' direction. */ |
no test coverage detected