allocate space for an object's name; removes old name if there is one */
| 58 | |
| 59 | /* allocate space for an object's name; removes old name if there is one */ |
| 60 | void |
| 61 | new_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 */ |
| 80 | void |
no test coverage detected