Skip to content

Commit ec4754b

Browse files
committed
Implements proper iter dispose
1 parent dfe142f commit ec4754b

File tree

2 files changed

+393
-34
lines changed

2 files changed

+393
-34
lines changed

leveldbstatic.nim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,11 @@ type
7777
LevelDbException* = object of CatchableError
7878

7979
IterNext* = proc(): (string, string) {.gcsafe, closure.}
80+
IterDispose* = proc() {.gcsafe, closure.}
8081
LevelDbQueryIter* = ref object
8182
finished*: bool
8283
next*: IterNext
84+
dispose*: IterDispose
8385

8486
const
8587
version* = block:
@@ -477,8 +479,13 @@ proc queryIter*(self: LevelDb, prefix: string = "", keysOnly: bool = false, skip
477479
else:
478480
return (keyStr, valueStr)
479481

482+
proc dispose() {.gcsafe, closure.} =
483+
if not iter.finished:
484+
iter.closeIter(iterPtr)
485+
480486
iter.finished = false
481487
iter.next = getNext
488+
iter.dispose = dispose
482489
return iter
483490

484491
proc removeDb*(name: string) =

0 commit comments

Comments
 (0)