allocate space for an object's name; removes old name if there is one */
| 1193 | |
| 1194 | /* allocate space for an object's name; removes old name if there is one */ |
| 1195 | void |
| 1196 | new_oname(struct obj *obj, |
| 1197 | int lth) /* desired length (caller handles adding 1 |
| 1198 | for terminator) */ |
| 1199 | { |
| 1200 | if (lth) { |
| 1201 | /* allocate oextra if necessary; otherwise get rid of old name */ |
| 1202 | if (!obj->oextra) |
| 1203 | obj->oextra = newoextra(); |
| 1204 | else |
| 1205 | free_oname(obj); /* already has oextra, might also have name */ |
| 1206 | ONAME(obj) = (char *) alloc((unsigned) lth); |
| 1207 | } else { |
| 1208 | /* zero length: the new name is empty; get rid of the old name */ |
| 1209 | if (has_oname(obj)) |
| 1210 | free_oname(obj); |
| 1211 | } |
| 1212 | } |
| 1213 | |
| 1214 | /* release an object's name; retains oextra even if all fields are now null */ |
| 1215 | void |
nothing calls this directly
no test coverage detected