summaryrefslogtreecommitdiff
path: root/xmake/core/base/bytes.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2021-09-21 00:35:04 +0800
committerruki <[email protected]>2021-09-21 00:35:04 +0800
commitde47ad0121ca4155777005976b05debeda67aca6 (patch)
tree0cb535481ec2f4522ed73f73b663d30e40a054b5 /xmake/core/base/bytes.lua
parent6bd955fbacc03792d8b36dffa087967e9e056e31 (diff)
add byteof
Diffstat (limited to 'xmake/core/base/bytes.lua')
-rw-r--r--xmake/core/base/bytes.lua4
1 files changed, 2 insertions, 2 deletions
diff --git a/xmake/core/base/bytes.lua b/xmake/core/base/bytes.lua
index f35f20790..0486f0178 100644
--- a/xmake/core/base/bytes.lua
+++ b/xmake/core/base/bytes.lua
@@ -138,7 +138,7 @@ function _instance.new(...)
os.raise("incorrect bounds(%d-%d)!", start, last)
end
instance._SIZE = last - start + 1
- instance._CDATA = b:cdata() - 1 + start
+ instance._CDATA = libc.diffptr(b:cdata(), -1 + start)
instance._REF = b -- keep lua ref for GC
instance._MANAGED = false
instance._READONLY = b:readonly()
@@ -390,7 +390,7 @@ function _instance:__index(key)
if key < 1 or key > self:size() then
os.raise("%s: index(%d/%d) out of bounds!", self, key, self:size())
end
- return self._CDATA[key - 1]
+ return libc.byteof(self._CDATA, key - 1)
elseif type(key) == "table" then
local start, last = key[1], key[2]
return self:slice(start, last)