allocate space for a monster's name; removes old name if there is one */
| 906 | |
| 907 | /* allocate space for a monster's name; removes old name if there is one */ |
| 908 | void |
| 909 | new_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 */ |
| 928 | void |
nothing calls this directly
no test coverage detected