Skip to content

Instantly share code, notes, and snippets.

@huxuan
huxuan / Makefile
Last active February 26, 2023 17:33
Hello World for LuaJIT FFI/C++ binding.
all: lib run
lib:
g++ -shared -fPIC -o libhello.so libhello.cpp hello.cpp
run:
luajit main.lua
clean:
rm *.so
@zeux
zeux / crtheap.cpp
Created February 12, 2016 08:26
Overriding CRT heap functions to use a custom allocator.
// User-defined global heap prototypes
extern void mem_global_init();
extern void mem_global_term();
extern void* mem_global_allocate(size_t size, size_t align);
extern void mem_global_deallocate(void* ptr);
extern size_t mem_global_get_size(void* ptr);
// Actual code
#define BREAK() __debugbreak()
@mrluanma
mrluanma / luajit_ffi_exe.c
Created April 13, 2013 17:00
Embedding LUA to an Executable using LuaJIT/FFI via: http://forums.4fips.com/viewtopic.php?f=3&t=589
/*
(c) 2012 +++ Filip Stoklas, aka FipS, http://www.4FipS.com +++
THIS CODE IS FREE - LICENSED UNDER THE MIT LICENSE
ARTICLE URL: http://forums.4fips.com/viewtopic.php?f=3&t=589
*/
extern "C" {
#include <lua.h>
#include <lualib.h>