Add Lua 5.1 compatibility definitions to lua c binding; fix realloc error check for openwrt.