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

Function new_mgivenname

src/do_name.c:30–47  ·  view source on GitHub ↗

allocate space for a monster's name; removes old name if there is one */

Source from the content-addressed store, hash-verified

28
29/* allocate space for a monster's name; removes old name if there is one */
30void
31new_mgivenname(
32 struct monst *mon,
33 int lth) /* desired length (caller handles adding 1 for terminator) */
34{
35 if (lth) {
36 /* allocate mextra if necessary; otherwise get rid of old name */
37 if (!mon->mextra)
38 mon->mextra = newmextra();
39 else
40 free_mgivenname(mon); /* has mextra, might also have name */
41 MGIVENNAME(mon) = (char *) alloc((unsigned) lth);
42 } else {
43 /* zero length: the new name is empty; get rid of the old name */
44 if (has_mgivenname(mon))
45 free_mgivenname(mon);
46 }
47}
48
49/* release a monster's name; retains mextra even if all fields are now null */
50void

Callers 3

christen_monstFunction · 0.70
restmonFunction · 0.70
copy_mextraFunction · 0.70

Calls 3

newmextraFunction · 0.70
free_mgivennameFunction · 0.70
allocFunction · 0.70

Tested by

no test coverage detected