Skip to content

Commit

Permalink
#416 Added iterator resource cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderMertens committed Dec 2, 2015
1 parent 02d847f commit c760a2e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/corto/lang/src/corto_ll.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ corto_iter _corto_llIter(corto_ll list, void *udata) {
result.remove = corto_llIterRemove;
result.insert = corto_llIterInsert;
result.set = corto_llIterSet;
result.release = NULL;

return result;
}
Expand All @@ -361,6 +362,7 @@ corto_iter corto_llIterAlloc(corto_ll list) {

void corto_llIterRelease(corto_iter *iter) {
corto_dealloc(iter->udata);
iter->udata = NULL;
}

void corto_llIterMoveFirst(corto_iter* iter) {
Expand Down
5 changes: 5 additions & 0 deletions packages/corto/lang/src/corto_select.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,10 @@ static void corto_selectRequestReplicators(

static void corto_selectIterateReplicators(corto_selectData *data) {
if (data->activeReplicators) {
if (data->currentReplicator < 0) {
data->currentReplicator = 0;
}

/* Walk over iterators until one with data available has been found */
while ((data->currentReplicator < data->activeReplicators)) {
corto_resultIter *iter = &data->replicators[data->currentReplicator];
Expand Down Expand Up @@ -418,6 +422,7 @@ static void corto_selectIterateReplicators(corto_selectData *data) {
/* Return item */
break;
} else {
corto_iterRelease(iter);
data->currentReplicator ++;
}
}
Expand Down

0 comments on commit c760a2e

Please sign in to comment.