本文整理汇总了C++中sizeudata函数的典型用法代码示例。如果您正苦于以下问题:C++ sizeudata函数的具体用法?C++ sizeudata怎么用?C++ sizeudata使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sizeudata函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: freeobj
static void freeobj (lua_State *L, GCObject *o) {
switch (o->tt) {
case LUA_TPROTO: luaF_freeproto(L, gco2p(o)); break;
case LUA_TLCL: {
freeLclosure(L, gco2lcl(o));
break;
}
case LUA_TCCL: {
luaM_freemem(L, o, sizeCclosure(gco2ccl(o)->nupvalues));
break;
}
case LUA_TTABLE: luaH_free(L, gco2t(o)); break;
case LUA_TTHREAD: luaE_freethread(L, gco2th(o)); break;
case LUA_TUSERDATA: luaM_freemem(L, o, sizeudata(gco2u(o))); break;
case LUA_TSHRSTR:
luaS_remove(L, gco2ts(o)); /* remove it from hash table */
luaM_freemem(L, o, sizelstring(gco2ts(o)->shrlen));
break;
case LUA_TLNGSTR: {
luaM_freemem(L, o, sizelstring(gco2ts(o)->u.lnglen));
break;
}
default: lua_assert(0);
}
}
开发者ID:charleeli,项目名称:srpc,代码行数:25,代码来源:lgc.c
示例2: luaC_separateudata
/* move `dead' udata that need finalization to list `tmudata' */
size_t luaC_separateudata (lua_State *L, int all) {
global_State *g = G(L);
size_t deadmem = 0;
GCObject **p = &g->mainthread->next;
GCObject *curr;
while ((curr = *p) != NULL) {
if (!(iswhite(curr) || all) || isfinalized(gco2u(curr)))
p = &curr->gch.next; /* don't bother with them */
else if (fasttm(L, gco2u(curr)->metatable, TM_GC) == NULL) {
markfinalized(gco2u(curr)); /* don't need finalization */
p = &curr->gch.next;
}
else { /* must call its gc method */
deadmem += sizeudata(gco2u(curr));
markfinalized(gco2u(curr));
*p = curr->gch.next;
/* link `curr' at the end of `tmudata' list */
if (g->tmudata == NULL) /* list is empty? */
g->tmudata = curr->gch.next = curr; /* creates a circular list */
else {
curr->gch.next = g->tmudata->gch.next;
g->tmudata->gch.next = curr;
g->tmudata = curr;
}
}
}
return deadmem;
}
开发者ID:VargMon,项目名称:netbsd-cvs-mirror,代码行数:29,代码来源:lgc.c
示例3: freeobj
static void freeobj (lua_State *L, GCObject *o) {
switch (gch(o)->tt) {
case LUA_TPROTO: luaF_freeproto(L, gco2p(o)); break;
case LUA_TLCL: {
luaM_freemem(L, o, sizeLclosure(gco2lcl(o)->nupvalues));
break;
}
case LUA_TCCL: {
luaM_freemem(L, o, sizeCclosure(gco2ccl(o)->nupvalues));
break;
}
case LUA_TUPVAL: luaF_freeupval(L, gco2uv(o)); break;
case LUA_TTABLE: luaH_free(L, gco2t(o)); break;
case LUA_TTHREAD: luaE_freethread(L, gco2th(o)); break;
case LUA_TUSERDATA: luaM_freemem(L, o, sizeudata(gco2u(o))); break;
case LUA_TSHRSTR:
G(L)->strt.nuse--;
/* go through */
case LUA_TLNGSTR: {
luaM_freemem(L, o, sizestring(gco2ts(o)));
break;
}
default: lua_assert(0);
}
}
开发者ID:crazii,项目名称:mameplus,代码行数:25,代码来源:lgc.c
示例4: freeobj
static void freeobj (lua_State *L, GCObject *o) {
switch (o->gch.tt) {
case LUA_TPROTO: luaF_freeproto(L, gcotop(o)); break;
case LUA_TFUNCTION: luaF_freeclosure(L, gcotocl(o)); break;
case LUA_TUPVAL: luaM_freelem(L, gcotouv(o)); break;
case LUA_TTABLE: luaH_free(L, gcotoh(o)); break;
case LUA_TTHREAD: {
lua_assert(gcototh(o) != L && gcototh(o) != G(L)->mainthread);
luaE_freethread(L, gcototh(o));
break;
}
case LUA_TSTRING: {
luaM_free(L, o, sizestring(gcotots(o)->tsv.len));
break;
}
case LUA_TWSTRING: {
luaM_free(L, o, sizewstring(gcototws(o)->tsv.len));
break;
}
case LUA_TUSERDATA: {
luaM_free(L, o, sizeudata(gcotou(o)->uv.len));
break;
}
#if LUA_REFCOUNT
case LUA_TNIL: {
break; // Do nothing.
}
#endif LUA_REFCOUNT
default: lua_assert(0);
}
}
开发者ID:gitrider,项目名称:wxsj2,代码行数:31,代码来源:lgc.c
示例5: luaC_separateudata
/* move `dead' udata that need finalization to list `tmudata' */
size_t luaC_separateudata (lua_State *L) {
size_t deadmem = 0;
GCObject **p = &G(L)->rootudata;
GCObject *curr;
GCObject *collected = NULL; /* to collect udata with gc event */
GCObject **lastcollected = &collected;
while ((curr = *p) != NULL) {
lua_assert(curr->gch.tt == LUA_TUSERDATA);
if (ismarked(curr) || isfinalized(gcotou(curr)))
p = &curr->gch.next; /* don't bother with them */
else if (fasttm(L, gcotou(curr)->uv.metatable, TM_GC) == NULL) {
markfinalized(gcotou(curr)); /* don't need finalization */
p = &curr->gch.next;
}
else { /* must call its gc method */
deadmem += sizeudata(gcotou(curr)->uv.len);
*p = curr->gch.next;
curr->gch.next = NULL; /* link `curr' at the end of `collected' list */
*lastcollected = curr;
lastcollected = &curr->gch.next;
}
}
/* insert collected udata with gc event into `tmudata' list */
*lastcollected = G(L)->tmudata;
G(L)->tmudata = collected;
return deadmem;
}
开发者ID:nuclewall,项目名称:bsdinstaller,代码行数:29,代码来源:lgc.c
示例6: freeobj
static void freeobj(lua_State *L, GCObject *o) {
switch (o->gch.tt) {
case LUA_TPROTO:
luaF_freeproto(L, gco2p(o));
break;
case LUA_TFUNCTION:
luaF_freeclosure(L, gco2cl(o));
break;
case LUA_TUPVAL:
luaF_freeupval(L, gco2uv(o));
break;
case LUA_TTABLE:
luaH_free(L, gco2h(o));
break;
case LUA_TTHREAD: {
lua_assert(gco2th(o) != L && gco2th(o) != G(L)->mainthread);
luaE_freethread(L, gco2th(o));
break;
}
case LUA_TSTRING: {
G(L)->strt.nuse--;
luaM_freemem(L, o, sizestring(gco2ts(o)));
break;
}
case LUA_TUSERDATA: {
luaM_freemem(L, o, sizeudata(gco2u(o)));
break;
}
default:
lua_assert(0);
}
}
开发者ID:wayling,项目名称:xboot-clone,代码行数:32,代码来源:lgc.c
示例7: reallymarkobject
/*
** mark an object. Userdata, strings, and closed upvalues are visited
** and turned black here. Other objects are marked gray and added
** to appropriate list to be visited (and turned black) later. (Open
** upvalues are already linked in 'headuv' list.)
*/
static void reallymarkobject (global_State *g, GCObject *o) {
lu_mem size;
white2gray(o);
switch (gch(o)->tt) {
case LUA_TSHRSTR:
case LUA_TLNGSTR: {
size = sizestring(gco2ts(o));
break; /* nothing else to mark; make it black */
}
case LUA_TUSERDATA: {
Table *mt = gco2u(o)->metatable;
markobject(g, mt);
markobject(g, gco2u(o)->env);
size = sizeudata(gco2u(o));
break;
}
case LUA_TUPVAL: {
UpVal *uv = gco2uv(o);
markvalue(g, uv->v);
if (uv->v != &uv->u.value) /* open? */
return; /* open upvalues remain gray */
size = sizeof(UpVal);
break;
}
case LUA_TLCL: {
gco2lcl(o)->gclist = g->gray;
g->gray = o;
return;
}
case LUA_TCCL: {
gco2ccl(o)->gclist = g->gray;
g->gray = o;
return;
}
case LUA_TTABLE: {
linktable(gco2t(o), &g->gray);
return;
}
case LUA_TTHREAD: {
gco2th(o)->gclist = g->gray;
g->gray = o;
return;
}
case LUA_TPROTO: {
gco2p(o)->gclist = g->gray;
g->gray = o;
return;
}
default: lua_assert(0); return;
}
gray2black(o);
g->GCmemtrav += size;
}
开发者ID:crazii,项目名称:mameplus,代码行数:59,代码来源:lgc.c
示例8: reallymarkobject
/*
** mark an object. Userdata, strings, and closed upvalues are visited
** and turned black here. Other objects are marked gray and added
** to appropriate list to be visited (and turned black) later. (Open
** upvalues are already linked in 'headuv' list.)
*/
static void reallymarkobject (global_State *g, GCObject *o) {
reentry:
white2gray(o);
switch (o->tt) {
case LUA_TSHRSTR: {
gray2black(o);
g->GCmemtrav += sizelstring(gco2ts(o)->shrlen);
break;
}
case LUA_TLNGSTR: {
gray2black(o);
g->GCmemtrav += sizelstring(gco2ts(o)->u.lnglen);
break;
}
case LUA_TUSERDATA: {
TValue uvalue;
markobjectN(g, gco2u(o)->metatable); /* mark its metatable */
gray2black(o);
g->GCmemtrav += sizeudata(gco2u(o));
getuservalue(g->mainthread, gco2u(o), &uvalue);
if (valiswhite(&uvalue)) { /* markvalue(g, &uvalue); */
o = gcvalue(&uvalue);
goto reentry;
}
break;
}
case LUA_TLCL: {
linkgclist(gco2lcl(o), g->gray);
break;
}
case LUA_TCCL: {
linkgclist(gco2ccl(o), g->gray);
break;
}
case LUA_TTABLE: {
linkgclist(gco2t(o), g->gray);
break;
}
case LUA_TTHREAD: {
linkgclist(gco2th(o), g->gray);
break;
}
case LUA_TPROTO: {
linkgclist(gco2p(o), g->gray);
break;
}
default:
lua_assert(0);
break;
}
}
开发者ID:scw000000,项目名称:Engine,代码行数:57,代码来源:lgc.c
示例9: freeobj
static void freeobj (lua_State *L, GCObject *o) {
global_State *g = G(L);
lua_assert(is_robj(o));
switch (o->gch.tt) {
case LUA_TPROTO:
luaF_freeproto(L, gco2p(o));
break;
case LUA_TFUNCTION:
luaF_freeclosure(L, gco2cl(o));
break;
case LUA_TUPVAL:
luaF_freeupval(L, gco2uv(o));
break;
case LUA_TTABLE:
luaH_free(L, gco2h(o));
break;
case LUA_TTHREAD: {
lua_assert(gco2th(o) != L && gco2th(o) != G(L)->mainthread);
luaE_freethread(L, gco2th(o));
break;
}
case LUA_TSTRING: {
G(L)->strt.nuse--;
luaM_freemem(L, o, sizestring(gco2ts(o)));
break;
}
case LUA_TUSERDATA: {
const Udata *udata = rawgco2u(o);
const TValue *tm = fasttm(L, udata->uv.metatable, TM_GC);
if (tm != NULL) {
lu_byte oldah = L->allowhook;
lu_mem oldt = g->GCthreshold;
L->allowhook = 0; /* stop debug hooks during GC tag method */
g->GCthreshold = 2*g->totalbytes; /* avoid GC steps */
setobj2s(L, L->top, tm);
setuvalue(L, L->top+1, udata);
L->top += 2;
luaD_call(L, L->top - 2, 0);
L->allowhook = oldah; /* restore hooks */
g->GCthreshold = oldt; /* restore threshold */
}
luaM_freemem(L, o, sizeudata(gco2u(o)));
break;
}
default:
lua_assert(0);
}
}
开发者ID:hogelog,项目名称:ostacklua,代码行数:48,代码来源:lregion.c
示例10: lj_udata_free
void LJ_FASTCALL lj_udata_free(global_State *g, GCudata *ud)
{
lj_mem_free(g, ud, sizeudata(ud));
}
开发者ID:449306923,项目名称:uLui,代码行数:4,代码来源:lj_udata.c
示例11: cleartable
static void cleartable (lua_State *L, GCObject *l) {
#else
static void cleartable (GCObject *l) {
#endif /* LUA_REFCOUNT */
while (l) {
Table *h = gco2h(l);
int i = h->sizearray;
lua_assert(testbit(h->marked, VALUEWEAKBIT) ||
testbit(h->marked, KEYWEAKBIT));
if (testbit(h->marked, VALUEWEAKBIT)) {
while (i--) {
TValue *o = &h->array[i];
#if LUA_REFCOUNT
if (iscleared(o, 0)) { /* value was collected? */
if (iscollectable(o))
o->value.gc->gch.ref--;
setnilvalue2n(l, o); /* remove value */
}
#else
if (iscleared(o, 0)) /* value was collected? */
setnilvalue(o); /* remove value */
#endif /* LUA_REFCOUNT */
}
}
i = sizenode(h);
while (i--) {
Node *n = gnode(h, i);
if (!ttisnil(gval(n)) && /* non-empty entry? */
(iscleared(key2tval(n), 1) || iscleared(gval(n), 0))) {
#if LUA_REFCOUNT
if (iscollectable(gval(n)))
gval(n)->value.gc->gch.ref--;
setnilvalue2n(L, gval(n)); /* remove value ... */
#else
setnilvalue(gval(n)); /* remove value ... */
#endif /* LUA_REFCOUNT */
removeentry(n); /* remove entry from table */
}
}
l = h->gclist;
}
}
static void freeobj (lua_State *L, GCObject *o) {
switch (o->gch.tt) {
case LUA_TPROTO: luaF_freeproto(L, gco2p(o)); break;
case LUA_TFUNCTION: luaF_freeclosure(L, gco2cl(o)); break;
case LUA_TUPVAL: luaF_freeupval(L, gco2uv(o)); break;
case LUA_TTABLE: luaH_free(L, gco2h(o)); break;
case LUA_TTHREAD: {
lua_assert(gco2th(o) != L && gco2th(o) != G(L)->mainthread);
luaE_freethread(L, gco2th(o));
break;
}
case LUA_TSTRING: {
G(L)->strt.nuse--;
luaM_freemem(L, o, sizestring(gco2ts(o)));
break;
}
#if LUA_WIDESTRING
case LUA_TWSTRING: {
G(L)->strt.nuse--;
luaM_freemem(L, o, sizestring(gco2ts(o)));
break;
}
#endif /* LUA_WIDESTRING */
case LUA_TUSERDATA: {
luaM_freemem(L, o, sizeudata(gco2u(o)));
break;
}
default: lua_assert(0);
}
}
#define sweepwholelist(L,p) sweeplist(L,p,MAX_LUMEM)
static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) {
GCObject *curr;
global_State *g = G(L);
int deadmask = otherwhite(g);
while ((curr = *p) != NULL && count-- > 0) {
if (curr->gch.tt == LUA_TTHREAD) /* sweep open upvalues of each thread */
sweepwholelist(L, &gco2th(curr)->openupval);
if ((curr->gch.marked ^ WHITEBITS) & deadmask) { /* not dead? */
lua_assert(!isdead(g, curr) || testbit(curr->gch.marked, FIXEDBIT));
makewhite(g, curr); /* make it white (for next cycle) */
p = &curr->gch.next;
}
else { /* must erase `curr' */
lua_assert(isdead(g, curr) || deadmask == bitmask(SFIXEDBIT));
#if LUA_REFCOUNT
if (curr->gch.prev)
curr->gch.prev->gch.next = curr->gch.next;
if (curr->gch.next)
curr->gch.next->gch.prev = (GCObject*)p;
#endif /* LUA_REFCOUNT */
//.........这里部分代码省略.........
开发者ID:zapline,项目名称:zlib,代码行数:101,代码来源:lgc.c
示例12: marktmu
static void marktmu (GCState *st) {
GCObject *u;
#if LUA_REFCOUNT
for (u = st->g->tmudata_head.next; u != (GCObject*)&st->g->tmudata_tail; u = u->gch.next) {
#else !LUA_REFCOUNT
for (u = st->g->tmudata; u; u = u->gch.next) {
#endif LUA_REFCOUNT
unmark(u); /* may be marked, if left from previous GC */
reallymarkobject(st, u);
}
}
/* move `dead' udata that need finalization to list `tmudata' */
size_t luaC_separateudata (lua_State *L) {
size_t deadmem = 0;
#if LUA_REFCOUNT
GCObject **p = &G(L)->rootudata_head.next;
#else !LUA_REFCOUNT
GCObject **p = &G(L)->rootudata;
#endif LUA_REFCOUNT
GCObject *curr;
GCObject *collected = NULL; /* to collect udata with gc event */
#if !LUA_REFCOUNT
GCObject **lastcollected = &collected;
while ((curr = *p) != NULL) {
lua_assert(curr->gch.tt == LUA_TUSERDATA);
#else LUA_REFCOUNT
while ((curr = *p) != (GCObject*)&G(L)->rootudata_tail) {
#endif LUA_REFCOUNT
if (ismarked(curr) || isfinalized(gcotou(curr)))
p = &curr->gch.next; /* don't bother with them */
else if (fasttm(L, gcotou(curr)->uv.metatable, TM_GC) == NULL) {
markfinalized(gcotou(curr)); /* don't need finalization */
p = &curr->gch.next;
}
else { /* must call its gc method */
deadmem += sizeudata(gcotou(curr)->uv.len);
*p = curr->gch.next;
#if LUA_REFCOUNT
Unlink(curr);
curr->gch.next = (GCObject*)&G(L)->tmudata_tail; /* link `curr' at the end of `collected' list */
curr->gch.prev = G(L)->tmudata_tail.prev;
G(L)->tmudata_tail.prev->gch.next = curr;
G(L)->tmudata_tail.prev = curr;
#else !LUA_REFCOUNT
curr->gch.next = NULL; /* link `curr' at the end of `collected' list */
*lastcollected = curr;
lastcollected = &curr->gch.next;
#endif LUA_REFCOUNT
}
}
/* insert collected udata with gc event into `tmudata' list */
#if LUA_REFCOUNT
// *lastcollected = G(L)->tmudata_head.next;
// G(L)->tmudata_head.next = collected;
#else !LUA_REFCOUNT
*lastcollected = G(L)->tmudata;
G(L)->tmudata = collected;
#endif LUA_REFCOUNT
return deadmem;
}
static void removekey (lua_State *L, Node *n) {
(void)L;
setnilvalue(gval(n)); /* remove corresponding value ... */
if (iscollectable(gkey(n)))
setttype(gkey(n), LUA_TNONE); /* dead key; remove it */
}
开发者ID:gitrider,项目名称:wxsj2,代码行数:71,代码来源:lgc.c
注:本文中的sizeudata函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论