diff options
author | Oran Agra <oran@monfort.co.il> | 2016-04-25 16:49:57 +0300 |
---|---|---|
committer | Oran Agra <oran@monfort.co.il> | 2016-04-25 16:49:57 +0300 |
commit | 5e3880a492efd6c305d7bde5be44c1de72e15cb0 (patch) | |
tree | 420a30abd62505ec7624c45db9b4b4e69d33956d /src/adlist.c | |
parent | 6ed8c2823065fc32bd8eaa63b42ca41a82b25b39 (diff) | |
download | redis-5e3880a492efd6c305d7bde5be44c1de72e15cb0.tar.gz |
various cleanups and minor fixes
Diffstat (limited to 'src/adlist.c')
-rw-r--r-- | src/adlist.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/src/adlist.c b/src/adlist.c index b4cc785be..f171d3ecc 100644 --- a/src/adlist.c +++ b/src/adlist.c @@ -242,7 +242,7 @@ listNode *listNext(listIter *iter) list *listDup(list *orig) { list *copy; - listIter *iter; + listIter iter; listNode *node; if ((copy = listCreate()) == NULL) @@ -250,26 +250,23 @@ list *listDup(list *orig) copy->dup = orig->dup; copy->free = orig->free; copy->match = orig->match; - iter = listGetIterator(orig, AL_START_HEAD); - while((node = listNext(iter)) != NULL) { + listRewind(orig, &iter); + while((node = listNext(&iter)) != NULL) { void *value; if (copy->dup) { value = copy->dup(node->value); if (value == NULL) { listRelease(copy); - listReleaseIterator(iter); return NULL; } } else value = node->value; if (listAddNodeTail(copy, value) == NULL) { listRelease(copy); - listReleaseIterator(iter); return NULL; } } - listReleaseIterator(iter); return copy; } @@ -284,24 +281,21 @@ list *listDup(list *orig) * NULL is returned. */ listNode *listSearchKey(list *list, void *key) { - listIter *iter; + listIter iter; listNode *node; - iter = listGetIterator(list, AL_START_HEAD); - while((node = listNext(iter)) != NULL) { + listRewind(list, &iter); + while((node = listNext(&iter)) != NULL) { if (list->match) { if (list->match(node->value, key)) { - listReleaseIterator(iter); return node; } } else { if (key == node->value) { - listReleaseIterator(iter); return node; } } } - listReleaseIterator(iter); return NULL; } |