Disambiguate allocator and memory

This commit is contained in:
Rerumu
2022-01-17 01:59:02 -05:00
parent 5fb7899c7e
commit 02232b46ca
5 changed files with 15 additions and 15 deletions
+5 -5
View File
@@ -320,7 +320,7 @@ end
do
local load = {}
local store = {}
local memory = {}
local allocator = {}
ffi.cdef([[
union Any {
@@ -465,7 +465,7 @@ do
ffi.fill(by_offset(memory.data, old), new - old, 0)
end
function memory.new(min, max)
function allocator.new(min, max)
local data = ffi.C.calloc(max, WASM_PAGE_SIZE)
assert(data ~= nil, "failed to allocate")
@@ -475,11 +475,11 @@ do
return ffi.gc(memory, finalizer)
end
function memory.init(memory, addr, data)
function allocator.init(memory, addr, data)
ffi.copy(by_offset(memory.data, addr), data, #data - 1)
end
function memory.grow(memory, num)
function allocator.grow(memory, num)
local old = memory.min
local new = old + num
@@ -495,7 +495,7 @@ do
module.load = load
module.store = store
module.memory = memory
module.allocator = allocator
end
return module
+5 -5
View File
@@ -239,7 +239,7 @@ end
do
local load = {}
local store = {}
local memory = {}
local allocator = {}
local function rip_u64(x)
return math.floor(x / 0x100000000), x % 0x100000000
@@ -327,11 +327,11 @@ do
store.i32(memory, addr + 4, hi)
end
function memory.new(min, max)
function allocator.new(min, max)
return { min = min, max = max, data = {} }
end
function memory.init(memory, offset, data)
function allocator.init(memory, offset, data)
local store_i8 = module.store.i32_n8
local store_i32 = module.store.i32
@@ -351,7 +351,7 @@ do
end
end
function memory.grow(memory, num)
function allocator.grow(memory, num)
local old = memory.min
local new = old + num
@@ -366,7 +366,7 @@ do
module.load = load
module.store = store
module.memory = memory
module.allocator = allocator
end
return module