MCPcopy Index your code
hub / github.com/NetHack/NetHack / l_obj_gc

Function l_obj_gc

src/nhlobj.c:46–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44}
45
46staticfn int
47l_obj_gc(lua_State *L)
48{
49 struct obj *obj, *otmp;
50 struct _lua_obj *lo = l_obj_check(L, 1);
51
52 if (lo && (obj = lo->obj) != 0) {
53 if (obj->lua_ref_cnt > 0)
54 obj->lua_ref_cnt--;
55 /* free-floating objects with no other refs are deallocated. */
56 if (!obj->lua_ref_cnt
57 && (obj->where == OBJ_FREE || obj->where == OBJ_LUAFREE)) {
58 if (Has_contents(obj)) {
59 while ((otmp = obj->cobj) != 0) {
60 obj_extract_self(otmp);
61 dealloc_obj(otmp);
62 }
63 }
64 obj->where = OBJ_FREE;
65 dealloc_obj(obj), obj = 0;
66 }
67 lo->obj = NULL;
68 }
69 return 0;
70}
71
72staticfn struct _lua_obj *
73l_obj_push(lua_State *L, struct obj *otmp)

Callers

nothing calls this directly

Calls 3

l_obj_checkFunction · 0.85
obj_extract_selfFunction · 0.85
dealloc_objFunction · 0.85

Tested by

no test coverage detected