Address some review comments; Apply the same destructor fix to the output stream
This commit is contained in:
parent
6ce0472ec0
commit
f3d1c8883f
3 changed files with 10 additions and 10 deletions
|
|
@ -53,17 +53,18 @@ const
|
|||
# The goal is to make perfect page-aligned allocations
|
||||
# defaultPageSize = 4096 - nimAllocatorMetadataSize
|
||||
|
||||
proc close*(s: var InputStream) {.raises: [IOError, Defect].} =
|
||||
if s != nil:
|
||||
if s.vtable != nil and s.vtable.closeSync != nil:
|
||||
s.vtable.closeSync(s)
|
||||
s = nil
|
||||
|
||||
proc preventFurtherReading(s: InputStream) =
|
||||
s.vtable = nil
|
||||
s.head = nil
|
||||
s.bufferEnd = nil
|
||||
|
||||
proc close*(s: InputStream) {.raises: [IOError, Defect].} =
|
||||
if s != nil:
|
||||
if s.vtable != nil and s.vtable.closeSync != nil:
|
||||
s.vtable.closeSync(s)
|
||||
|
||||
s.preventFurtherReading()
|
||||
|
||||
proc `=destroy`*(h: var InputStreamHandle) {.raises: [Defect].} =
|
||||
if h.s != nil:
|
||||
if h.s.vtable != nil and h.s.vtable.closeSync != nil:
|
||||
|
|
|
|||
|
|
@ -67,11 +67,10 @@ const
|
|||
# The goal is to make perfect page-aligned allocations
|
||||
defaultPageSize = 4096 - nimAllocatorMetadataSize - 1 # 1 byte for the null terminator
|
||||
|
||||
proc close*(s: var OutputStream) {.raises: [IOError, Defect].} =
|
||||
proc close*(s: OutputStream) {.raises: [IOError, Defect].} =
|
||||
if s != nil:
|
||||
if s.vtable != nil and s.vtable.closeSync != nil:
|
||||
s.vtable.closeSync(s)
|
||||
s = nil
|
||||
|
||||
proc `=destroy`*(h: var OutputStreamHandle) {.raises: [Defect].} =
|
||||
if h.s != nil:
|
||||
|
|
@ -83,7 +82,7 @@ proc `=destroy`*(h: var OutputStreamHandle) {.raises: [Defect].} =
|
|||
# If the user wanted to handle the error, they would have called
|
||||
# `close` manually.
|
||||
discard # TODO
|
||||
h.s = nil
|
||||
# h.s = nil
|
||||
|
||||
converter implicitDeref*(h: OutputStreamHandle): OutputStream =
|
||||
h.s
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue