File tree Expand file tree Collapse file tree 3 files changed +10
-6
lines changed Expand file tree Collapse file tree 3 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -4,3 +4,4 @@ BinDeps 0.8
4
4
CMakeWrapper 0.2
5
5
StaticArrays 0.5
6
6
FastIOBuffers 0.0.1
7
+ UnsafeArrays 0.2.0
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ module LCMCore
2
2
3
3
using StaticArrays
4
4
using FastIOBuffers
5
+ using UnsafeArrays
5
6
6
7
using Dates
7
8
using FileWatching: poll_fd
Original file line number Diff line number Diff line change @@ -146,12 +146,14 @@ end
146
146
147
147
function onresponse (rbuf:: RecvBuf , channelptr:: Ptr{UInt8} , opts:: SubscriptionOptions{T} ) where T
148
148
check_channel_name (channelptr, opts)
149
- msgdata = unsafe_wrap (Vector{UInt8}, rbuf. data, rbuf. data_size)
150
- if T === Nothing
151
- opts. handler (opts. channel, msgdata)
152
- else
153
- msg = decode (msgdata, opts. msgtype)
154
- opts. handler (opts. channel, msg)
149
+ GC. @preserve rbuf begin
150
+ msgdata = UnsafeArray (rbuf. data, (Int (rbuf. data_size), ))
151
+ if T === Nothing
152
+ opts. handler (opts. channel, msgdata)
153
+ else
154
+ msg = decode (msgdata, opts. msgtype)
155
+ opts. handler (opts. channel, msg)
156
+ end
155
157
end
156
158
return nothing
157
159
end
You can’t perform that action at this time.
0 commit comments