aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremias Stotter <jeremias@stotter.eu>2023-10-15 21:43:12 +0200
committerJeremias Stotter <jeremias@stotter.eu>2023-10-15 21:43:12 +0200
commit40adcb5686d1dc3d76a79e0a39c9631578074135 (patch)
treef69bbff420982dd41a72cedca2e263c4650428a8
parent3ceded204ece41bd3599e5da2369d7e6795bd159 (diff)
downloadnetwork-simulator-40adcb5686d1dc3d76a79e0a39c9631578074135.tar.gz
network-simulator-40adcb5686d1dc3d76a79e0a39c9631578074135.tar.bz2
network-simulator-40adcb5686d1dc3d76a79e0a39c9631578074135.zip
Use userdata for the device pointer in lua
-rw-r--r--device.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/device.c b/device.c
index 759e229..0a82bb4 100644
--- a/device.c
+++ b/device.c
@@ -32,7 +32,7 @@
struct device* start_device = NULL;
void dev_register_lua_function(struct device* dev, char* name, lua_CFunction fn) {
- lua_pushinteger(dev->lua_vm, (unsigned long)dev);
+ lua_pushlightuserdata(dev->lua_vm, dev);
lua_pushcclosure(dev->lua_vm, fn, 1);
lua_setglobal(dev->lua_vm, name);
}
@@ -44,7 +44,7 @@ void rename_device(struct device* dev, const char* name) {
}
struct device* get_dev_in_cfunc(lua_State* lua_vm) {
- return (struct device*)lua_tointeger(lua_vm, lua_upvalueindex(1));
+ return (struct device*)lua_topointer(lua_vm, lua_upvalueindex(1));
}
// Take in all the infos from the caller
Jeremias Stotters git repositories generated by CGIT