我在debug模式下面用CCLOG在dealloc函数里面输出一些信息,目的就是要检查场景的dealloc方法在replaceScene的时候有没有被调用,按照子龙山人大哥的说法,如果场景切换的时候dealloc没有调用,说明你这个场景的内存有问题。有可能被某个对象retain了,其retainCount在replaceScene的时候没有减少到0,所以dealloc方法是不会调用的。...
*/ typedef union UTString { L_Umaxalign dummy; /* ensures maximum alignment for strings 确保字符串的最大对齐 */ TString tsv; } UTString; TString结构是Lua中表示字符串的主体结构。UTString 结构主要是为了确保TString结构占用固定大小的内存区域,以便计算实际字符串存储的位置。
lua_pushlstring :在栈顶放入长度为 len 的字符序列作为 lua 字符串对象 const char *lua_pushlstring (lua_State *L, const char *s, size_t len); 把指针 s 指向的长度为 len 的字符串压栈。 Lua 对这个字符串做一个内部副本(或是复用一个副本), 因此s 处的内存在函数返回后,可以释放掉或是立刻重...
lua_pushlstring# [-0, +1, e] const char *lua_pushlstring (lua_State *L, const char *s, size_t len); 把指针 s 指向的长度为 len 的字符串压栈。 Lua 对这个字符串做一个内部副本(或是复用一个副本), 因此 s 处的内存在函数返回后,可以释放掉或是立刻重用于其它用途。 字符串内可以是任意...
TString结构体 我们平时在 lua 中使用到的字符串,在底层对应的数据结构是长什么样的,抱着好奇的心态去了解下。我们先写个最简单的字符串赋值语句 localname ="zhangsan" 接着看看这行代码对应的指令: main <tc.lua:0,0> (2instructions at00000000006c8490) ...
lua_pushlstring void lua_pushlstring (lua_State *L, const char *s, size_t len); 把指针s指向的长度为len的字符串压栈。 Lua 对这个字符串做一次内存拷贝(或是复用一个拷贝),因此s处的内存在函数返回后,可以释放掉或是重用于其它用途。字符串内可以保存有零字符。
void lua_pushlstring (lua_State *L, const char *s, size_t len); void lua_pushstring (lua_State *L, const char *s); 注意: Lua中的数值默认是double类型的,要压入整数的时候用lua_pushinteger Lua的string不是0字符结尾的,它可以包含任意二进制数据 ...
result = ucl_object_emit_len (obj, type, &len); if (result != NULL) { lua_pushstring (L, (const char *)result); lua_pushlstring (L, (const char *)result, len); free (result); } else { 0 comments on commit 3a04c92 Please sign in to comment. Footer...
lua_pushlstring(L, str + pos, l1 - pos); lua_rawseti(L, -2, ++idx); } break; } } return 1; } 然后按照惯例在strlib数组里的{NULL, NULL}之前添加: {"splitby", str_split}, 然后编译后,lua里便多了一个方法string.splitby。
点数使用lua_pushnumber;整型使用lua_pushinteger;任意字符串(一个指向char的指针,外加一个长度)使用lua_ pushlstring;以\0终止的字符串使用lua_pushstring。 (2)类型lua_Number相当于Lua语言中的浮点数类型,默认为 double,但可以在编译时配置Lua,让lua_Number为float甚至long double。类型lua_Integer相当于Lua语言...