You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
local str_type = ffi.typeof("uint8_t[?]")
local counter = 0
local BUF_MAX_REUSE = 10000
local BUF_MAX_LEN = 1024
local hex_buf = ffi_new(str_type, BUF_MAX_LEN)
function _M.to_hex(s)
local len = #s
local buf_len = len * 2
local buf
if buf_len <= BUF_MAX_LEN then
counter = counter + 1
if counter > BUF_MAX_REUSE then
hex_buf = ffi_new(str_type, BUF_MAX_LEN)
counter = 0
end
buf = hex_buf
else
buf = ffi_new(str_type, buf_len)
end
C.ngx_hex_dump(buf, s, len)
return ffi_str(buf, buf_len)
end
Activity
zhuizhuhaomeng commentedon Oct 29, 2022
I think it is a good idea.
but we need a better function name.
edo888 commentedon Oct 29, 2022
Does this look good?
zhuizhuhaomeng commentedon Nov 2, 2022
I final got what you mean.
Why do you need the max reuse time ?
edo888 commentedon Nov 2, 2022
I'm worried about burning out RAM when using to_hex heavily, so I'm asking your opinion about it. Is it a good idea or it should be fine? Thanks!