Skip to content

Commit

Permalink
core.packet: expose free_internal
Browse files Browse the repository at this point in the history
  • Loading branch information
eugeneia committed Nov 18, 2019
1 parent e056fa1 commit ee4e42d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 14 additions & 3 deletions src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,21 @@ Allocate packet and fill it with *length* bytes from *pointer*.

Allocate packet and fill it with the contents of *string*.

— Function **packet.clone_to_memory* *pointer* *packet*
— Function **packet.account_free** *packet*

Increment internal engine statistics (*frees*, *freebytes*, *freebits*) as if
*packet* were freed, but do not actually put it back onto the freelist.

This function is intended to be used by I/O apps in special cases that need
more finegrained control over packet freeing.

— Function **packet.free_internal** *packet*

Free *packet* and put it back onto the freelist, but do not increment internal
engine statistics (*frees*, *freebytes*, *freebits*).

See **packet.account_free**, **packet.free**.

Creates an exact copy of at memory pointed to by *pointer*. *Pointer* must
point to a `packet.packet_t`.

## Memory (core.memory)

Expand Down
2 changes: 1 addition & 1 deletion src/core/packet.lua
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ end
function from_string (d) return from_pointer(d, #d) end

-- Free a packet that is no longer in use.
local function free_internal (p)
function free_internal (p)
local ptr = ffi.cast("char*", p)
p = ffi.cast(packet_ptr_t, ptr - get_headroom(ptr) + default_headroom)
p.length = 0
Expand Down

0 comments on commit ee4e42d

Please sign in to comment.