Returns a list iterator 'iter'. After the initialization every * call to listNext() will return the next element of the list. * * This function can't fail. */
| 185 | * |
| 186 | * This function can't fail. */ |
| 187 | listIter *listGetIterator(list *list, int direction) |
| 188 | { |
| 189 | listIter *iter; |
| 190 | |
| 191 | if ((iter = zmalloc(sizeof(*iter), MALLOC_SHARED)) == NULL) return NULL; |
| 192 | if (direction == AL_START_HEAD) |
| 193 | iter->next = list->head; |
| 194 | else |
| 195 | iter->next = list->tail; |
| 196 | iter->direction = direction; |
| 197 | return iter; |
| 198 | } |
| 199 | |
| 200 | /* Release the iterator memory */ |
| 201 | void listReleaseIterator(listIter *iter) { |