Last active
December 8, 2019 01:14
-
-
Save arce/096171dd7a6bc2d376c384dd6175037e to your computer and use it in GitHub Desktop.
dataVector REDIS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//full userdata | |
extern "C" int newarray(lua_State* L) | |
{ | |
int n = luaL_checkint(L, 1); | |
size_t nbytes = sizeof(CharArray) + (n - 1)*sizeof(char); | |
CharArray* a = (CharArray*)lua_newuserdata(L, nbytes); | |
a->size = n; | |
return 1; | |
} | |
//light userdata | |
extern "C" int newlarray(lua_State* L) | |
{ | |
int n = luaL_checkint(L, 1); | |
size_t nbytes = sizeof(CharArray) + (n - 1)*sizeof(char); | |
CharArray* a = (CharArray*)(new char(nbytes)); | |
lua_pushlightuserdata(L,a); | |
a->size = n; | |
return 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment