Skip to content

Commit

Permalink
Packet.lua: add clone_to_memory
Browse files Browse the repository at this point in the history
  • Loading branch information
Katerina Barone-Adesi committed Aug 23, 2016
1 parent 048f2a8 commit bb9b3c2
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/core/packet.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,17 @@ function new_packet ()
return p
end

-- Create an exact copy of srcp at memory pointed to by dstp.
function clone_to_memory(dstp, srcp)
ffi.copy(dstp, srcp, srcp.length)
dstp.length = srcp.length
return dstp
end

-- Create an exact copy of a packet.
function clone (p)
local p2 = allocate()
ffi.copy(p2, p, p.length)
p2.length = p.length
return p2
return clone_to_memory(p2, p)
end

-- Append data to the end of a packet.
Expand Down

0 comments on commit bb9b3c2

Please sign in to comment.