mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
fix Bytearray from table constructor
This commit is contained in:
parent
b3a5ea8e06
commit
d9d65a169c
2 changed files with 4 additions and 1 deletions
|
|
@ -25,3 +25,6 @@ end
|
||||||
print(#arr, arr:get_capacity())
|
print(#arr, arr:get_capacity())
|
||||||
arr:trim()
|
arr:trim()
|
||||||
assert(#arr == arr:get_capacity())
|
assert(#arr == arr:get_capacity())
|
||||||
|
|
||||||
|
arr = Bytearray({0, 2, 7, 1, 16, 75, 25})
|
||||||
|
assert(arr[6] == 75)
|
||||||
|
|
|
||||||
|
|
@ -179,7 +179,7 @@ local FFIBytearray = {
|
||||||
return bytearray_type(buffer, #n, #n)
|
return bytearray_type(buffer, #n, #n)
|
||||||
elseif t == "table" then
|
elseif t == "table" then
|
||||||
local capacity = math.max(#n, MIN_CAPACITY)
|
local capacity = math.max(#n, MIN_CAPACITY)
|
||||||
local buffer = malloc(capacity)
|
local buffer = FFI.cast("unsigned char*", malloc(capacity))
|
||||||
for i=1,#n do
|
for i=1,#n do
|
||||||
buffer[i - 1] = n[i]
|
buffer[i - 1] = n[i]
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue