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

Function new_mgivenname

util/sfctool.c:908–925  ·  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

906
907/* allocate space for a monster's name; removes old name if there is one */
908void
909new_mgivenname(struct monst *mon,
910 int lth) /* desired length (caller handles adding 1
911 for terminator) */
912{
913 if (lth) {
914 /* allocate mextra if necessary; otherwise get rid of old name */
915 if (!mon->mextra)
916 mon->mextra = newmextra();
917 else
918 free_mgivenname(mon); /* already has mextra, might also have name */
919 MGIVENNAME(mon) = (char *) alloc((unsigned) lth);
920 } else {
921 /* zero length: the new name is empty; get rid of the old name */
922 if (has_mgivenname(mon))
923 free_mgivenname(mon);
924 }
925}
926
927/* release a monster's name; retains mextra even if all fields are now null */
928void

Callers

nothing calls this directly

Calls 3

newmextraFunction · 0.70
free_mgivennameFunction · 0.70
allocFunction · 0.50

Tested by

no test coverage detected