MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / listGetIterator

Function listGetIterator

src/adlist.c:187–198  ·  view source on GitHub ↗

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. */

Source from the content-addressed store, hash-verified

185 *
186 * This function can't fail. */
187listIter *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 */
201void listReleaseIterator(listIter *iter) {

Callers

nothing calls this directly

Calls 1

zmallocFunction · 0.85

Tested by

no test coverage detected