diff options
| author | ruki <[email protected]> | 2019-11-02 23:51:23 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-11-02 23:51:23 +0800 |
| commit | b0a7b7a70cafc7988a33e1856147622b0ea92559 (patch) | |
| tree | beecf055fd33bc2824f985b9f12af87fcd7f088d /xmake/core/base/bytes.lua | |
| parent | 4f932ba407833f9559a23037958c7388cc22d2e0 (diff) | |
fix ffi for linux
Diffstat (limited to 'xmake/core/base/bytes.lua')
| -rw-r--r-- | xmake/core/base/bytes.lua | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/xmake/core/base/bytes.lua b/xmake/core/base/bytes.lua index 17ed435ce..3b1fa141a 100644 --- a/xmake/core/base/bytes.lua +++ b/xmake/core/base/bytes.lua @@ -30,8 +30,8 @@ local utils = require("base/utils") -- define ffi interfaces ffi.cdef[[ - void* xm_ffi_malloc(unsigned long size); - void xm_ffi_free(void* data); + void* malloc(size_t size); + void free(void* data); ]] -- new a bytes instance @@ -55,7 +55,7 @@ function _instance.new(...) -- bytes(size, ptr [, manage]): mounts buffer on existing storage (manage memory or not) local manage = arg3 if manage then - instance._CDATA = ffi.gc(ffi.cast("unsigned char*", ptr), ffi.C.xm_ffi_free) + instance._CDATA = ffi.gc(ffi.cast("unsigned char*", ptr), ffi.C.free) instance._MANAGED = true else instance._CDATA = ffi.cast("unsigned char*", ptr) @@ -63,8 +63,8 @@ function _instance.new(...) end else -- bytes(size): allocates a buffer of given size - ptr = ffi.C.xm_ffi_malloc(size) - instance._CDATA = ffi.gc(ffi.cast("unsigned char*", ptr), ffi.C.xm_ffi_free) + ptr = ffi.C.malloc(size) + instance._CDATA = ffi.gc(ffi.cast("unsigned char*", ptr), ffi.C.free) instance._MANAGED = true end instance._SIZE = size @@ -97,7 +97,7 @@ function _instance.new(...) for _, b in ipairs(args) do instance._SIZE = instance._SIZE + b:size() end - instance._CDATA = ffi.gc(ffi.cast("unsigned char*", ffi.C.xm_ffi_malloc(instance._SIZE)), ffi.C.xm_ffi_free) + instance._CDATA = ffi.gc(ffi.cast("unsigned char*", ffi.C.malloc(instance._SIZE)), ffi.C.free) local offset = 0 for _, b in ipairs(args) do ffi.copy(instance._CDATA + offset, b:cdata(), b:size()) @@ -112,7 +112,7 @@ function _instance.new(...) for _, b in ipairs(args) do instance._SIZE = instance._SIZE + b:size() end - instance._CDATA = ffi.gc(ffi.cast("unsigned char*", ffi.C.xm_ffi_malloc(instance._SIZE)), ffi.C.xm_ffi_free) + instance._CDATA = ffi.gc(ffi.cast("unsigned char*", ffi.C.malloc(instance._SIZE)), ffi.C.free) local offset = 0 for _, b in ipairs(args) do ffi.copy(instance._CDATA + offset, b._CDATA, b:size()) |
