Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove finalizer #55

Merged
merged 3 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ TranscodingStreams = "3bb67fe8-82b1-5028-8e26-92a6c54297fa"
[compat]
ArgTools = "1"
BufferedStreams = "1"
CodecBzip2 = "0.6, 0.7, 0.8"
CodecBzip2 = "0.8.5"
SuffixArrays = "0.3, 1"
TranscodingStreams = "0.9.5, 0.10, 0.11"
julia = "1.6"
1 change: 0 additions & 1 deletion src/BSDiff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ function bspatch(
arg_write(new) do new_io
new_io = BufferedOutputStream(new_io)
apply_patch(patch_obj, old_data, new_io)
finalize(patch_obj)
flush(new_io)
end
end
Expand Down
11 changes: 1 addition & 10 deletions src/classic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ function ClassicPatch(patch_io::IO, new_size::Int64 = typemax(Int64))
diff = TranscodingStream(compressor(), IOBuffer())
data = TranscodingStream(compressor(), IOBuffer())
patch = ClassicPatch(patch_io, new_size, ctrl, diff, data)
finalizer(finalize_patch, patch)
return patch
end

Expand All @@ -36,17 +35,9 @@ function read_start(::Type{ClassicPatch}, patch_io::IO)
diff = TranscodingStream(decompressor(), diff_io)
data = TranscodingStream(decompressor(), data_io)
patch = ClassicPatch(patch_io, new_size, ctrl, diff, data)
finalizer(finalize_patch, patch)
return patch
end

function finalize_patch(patch::ClassicPatch)
for stream in (patch.ctrl, patch.diff, patch.data)
# must be called to avoid leaking memory
TranscodingStreams.changemode!(stream, :close)
end
end

function write_finish(patch::ClassicPatch)
for stream in (patch.ctrl, patch.diff, patch.data)
write(stream, TranscodingStreams.TOKEN_END)
Expand All @@ -61,7 +52,7 @@ function write_finish(patch::ClassicPatch)
write(patch.io, v)
end
flush(patch.io)
finalize(patch)
nothing
end

function encode_control(
Expand Down
10 changes: 1 addition & 9 deletions src/endsley.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ function write_start(
write_int(patch_io, new_size)
stream = TranscodingStream(compressor(), patch_io)
patch = EndsleyPatch(stream, new_size)
finalizer(finalize_patch, patch)
return patch
end

Expand All @@ -25,19 +24,12 @@ function read_start(::Type{EndsleyPatch}, patch_io::IO)
EndsleyPatch(TranscodingStream(decompressor(), patch_io), new_size)
end

function finalize_patch(patch::EndsleyPatch)
if patch.io isa TranscodingStream
# must be called to avoid leaking memory
TranscodingStreams.changemode!(patch.io, :close)
end
end

function write_finish(patch::EndsleyPatch)
if patch.io isa TranscodingStream
write(patch.io, TranscodingStreams.TOKEN_END)
end
flush(patch.io)
finalize(patch)
nothing
end

function encode_control(
Expand Down
Loading