/* ** Compute an initial seed as random as possible. Rely on Address Space ** Layout Randomization (if present) to increase randomness.. */ private static void addbuff(CharPtr b, int p, object e) { //https://blog.csdn.net/yingwang9/article/details/82215619 GCHandle handle1 = GCHandle.Alloc(e); IntPtr ptr = GCHandle.ToIntPtr(handle1); uint t = (uint)(ptr); memcpy(b + p, CharPtr.FromNumber(t), (uint)GetUnmanagedSize(typeof(uint))); p += GetUnmanagedSize(typeof(uint)); }
public static int luaK_numberK(FuncState fs, lua_Number r) { int n; lua_State L = fs.ls.L; TValue o = new TValue(); setnvalue(o, r); if (r == 0 || luai_numisnan(null, r)) /* handle -0 and NaN */ /* use raw representation as key to avoid numeric problems */ { setsvalue(L, L.top, luaS_newlstr(L, CharPtr.FromNumber(r), (uint)GetUnmanagedSize(typeof(lua_Number)))); StkId.inc(ref L.top); //FIXME:??? n = addk(fs, L.top - 1, o); StkId.dec(ref L.top); } else { n = addk(fs, o, o); /* regular case */ } return(n); }