allocate space for a monster's name; removes old name if there is one */
| 28 | |
| 29 | /* allocate space for a monster's name; removes old name if there is one */ |
| 30 | void |
| 31 | new_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 */ |
| 50 | void |
no test coverage detected