diff options
Diffstat (limited to 'stdlib/queue.ml')
-rw-r--r-- | stdlib/queue.ml | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/stdlib/queue.ml b/stdlib/queue.ml index 6d82d2593..fb920d8c9 100644 --- a/stdlib/queue.ml +++ b/stdlib/queue.ml @@ -107,14 +107,15 @@ let copy q = next = tail' } in - let rec copy cell = - if cell == tail then tail' - else { + let rec copy prev cell = + if cell != tail + then let res = { content = cell.content; - next = copy cell.next - } in + next = tail' + } in prev.next <- res; + copy res cell.next in - tail'.next <- copy tail.next; + copy tail' tail.next; { length = q.length; tail = tail' |