Skip to content

Commit

Permalink
Update lz4_compression.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash authored Feb 2, 2024
1 parent 0536b47 commit 700ad7c
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/lz4_compression.jl
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
const CINT_SIZE = sizeof(Cint)

function writeint(mem::Memory, int::Cint)
buf = reinterpret(UInt8, [int])

checkbounds(mem, CINT_SIZE)
unsafe_copyto!(mem.ptr, pointer(buf), CINT_SIZE)
checkbounds(mem, sizeof(Cint))
unsafe_store!(Ptr{Cint}(mem.ptr), int)
return CINT_SIZE
end

function readint(mem::Memory)
buf = Vector{UInt8}(undef, CINT_SIZE)

checkbounds(mem, CINT_SIZE)
unsafe_copyto!(pointer(buf), mem.ptr, CINT_SIZE)
return reinterpret(Cint, buf)[1]
checkbounds(mem, sizeof(Cint))
return unsafe_load(Ptr{Cint}(mem.ptr))
end

mutable struct SimpleDoubleBuffer
Expand Down

1 comment on commit 700ad7c

@vtjnash
Copy link
Contributor Author

@vtjnash vtjnash commented on 700ad7c Feb 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I was trying to test this in a PR, and didn't realize I had commit rights here so it would go straight to master. I enabled branch protection now so this won't happen again.

Please sign in to comment.