3 ** Copyright (C) 2005-2012 Mike Pall. See Copyright Notice in luajit.h
13 GCudata
*lj_udata_new(lua_State
*L
, MSize sz
, GCtab
*env
)
15 GCudata
*ud
= lj_mem_newt(L
, sizeof(GCudata
) + sz
, GCudata
);
16 global_State
*g
= G(L
);
17 newwhite(g
, ud
); /* Not finalized. */
19 ud
->udtype
= UDTYPE_USERDATA
;
21 /* NOBARRIER: The GCudata is new (marked white). */
22 setgcrefnull(ud
->metatable
);
23 setgcref(ud
->env
, obj2gco(env
));
24 /* Chain to userdata list (after main thread). */
25 setgcrefr(ud
->nextgc
, mainthread(g
)->nextgc
);
26 setgcref(mainthread(g
)->nextgc
, obj2gco(ud
));
30 void LJ_FASTCALL
lj_udata_free(global_State
*g
, GCudata
*ud
)
32 lj_mem_free(g
, ud
, sizeudata(ud
));