Data update
This commit is contained in:
parent
4d5544505c
commit
4924dd0264
3073 changed files with 55820 additions and 4408 deletions
|
|
@ -0,0 +1,18 @@
|
|||
/* mylib.c */
|
||||
|
||||
// gcc -c -fpic mylib.c
|
||||
// gcc -shared -o mylib.so mylib.o
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static void *strptr = NULL;
|
||||
|
||||
extern char *my_strdup(const char *src) {
|
||||
strptr = (void *)strdup(src);
|
||||
return (char *)strptr;
|
||||
}
|
||||
|
||||
extern void my_free() {
|
||||
free(strptr);
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
local ffi = require "pluto:ffi"
|
||||
local lib = ffi.open("./mylib.so")
|
||||
lib:cdef[[
|
||||
char *my_strdup(const char *src);
|
||||
void my_free();
|
||||
]]
|
||||
local s = "Hello World!"
|
||||
print(lib.my_strdup(s))
|
||||
lib.my_free()
|
||||
lib = nil
|
||||
Loading…
Add table
Add a link
Reference in a new issue