diff options
| author | ruki <[email protected]> | 2021-09-20 22:52:37 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-09-20 22:52:37 +0800 |
| commit | 68f4ab938564a43656236de3a0eb67f9222bc876 (patch) | |
| tree | e1df5be901cd0c63cdeaaf61218107a86d9e9d66 /xmake/core/base/libc.lua | |
| parent | 07cabd568b07120e227e29a945bc45dcc05a0db2 (diff) | |
improve bytes
Diffstat (limited to 'xmake/core/base/libc.lua')
| -rw-r--r-- | xmake/core/base/libc.lua | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/xmake/core/base/libc.lua b/xmake/core/base/libc.lua index ff6a88401..cedabef1b 100644 --- a/xmake/core/base/libc.lua +++ b/xmake/core/base/libc.lua @@ -46,6 +46,15 @@ function libc.malloc(size) end end +function libc.gcmalloc(size) + if ffi then + return ffi.gc(ffi.cast("unsigned char*", ffi.C.malloc(size)), ffi.C.free) + else + -- @note we need free it in lua/__gc manually + return libc._malloc(size) + end +end + function libc.free(data) if ffi then return ffi.C.free(data) |
