MCPcopy Create free account
hub / github.com/NetHack/NetHack / new_oname

Function new_oname

src/do_name.c:60–77  ·  view source on GitHub ↗

allocate space for an object's name; removes old name if there is one */

Source from the content-addressed store, hash-verified

58
59/* allocate space for an object's name; removes old name if there is one */
60void
61new_oname(
62 struct obj *obj,
63 int lth) /* desired length (caller handles adding 1 for terminator) */
64{
65 if (lth) {
66 /* allocate oextra if necessary; otherwise get rid of old name */
67 if (!obj->oextra)
68 obj->oextra = newoextra();
69 else
70 free_oname(obj); /* already has oextra, might also have name */
71 ONAME(obj) = (char *) alloc((unsigned) lth);
72 } else {
73 /* zero length: the new name is empty; get rid of the old name */
74 if (has_oname(obj))
75 free_oname(obj);
76 }
77}
78
79/* release an object's name; retains oextra even if all fields are now null */
80void

Callers 3

onameFunction · 0.70
restobjFunction · 0.70
migr_booty_itemFunction · 0.70

Calls 3

newoextraFunction · 0.70
free_onameFunction · 0.70
allocFunction · 0.70

Tested by

no test coverage detected