From dbc34e84e8cbdaa3b2482e825b44aec311eafc1b Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 21 May 2022 21:22:17 +0800 Subject: add clear for bloom filter --- xmake/core/base/bytes.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'xmake/core/base/bytes.lua') diff --git a/xmake/core/base/bytes.lua b/xmake/core/base/bytes.lua index daf51bc81..1103c8f6a 100644 --- a/xmake/core/base/bytes.lua +++ b/xmake/core/base/bytes.lua @@ -47,7 +47,8 @@ function _instance.new(...) local instance = table.inherit(_instance) if type(arg1) == "number" then local size = arg1 - if type(arg2) == "cdata" then + local arg2_type = type(arg2) + if arg2_type == "cdata" or arg2_type == "userdata" then -- bytes(size, ptr [, manage]): mounts buffer on existing storage (manage memory or not) local ptr = arg2 local manage = arg3 @@ -62,9 +63,9 @@ function _instance.new(...) -- bytes(size[, init]): allocates a buffer of given size local init if arg2 then - if type(arg2) == "number" then + if arg2_type == "number" then init = arg2 - elseif type(arg2) == "string" then + elseif arg2_type == "string" then init = arg2:byte() else os.raise("invalid arguments #2 for bytes(size, ...), cdata, string, number or nil expected!") -- cgit v1.3.1