strdup() which uses our alloc() rather than libc's malloc(); not used when MONITOR_HEAP is enabled, but included unconditionally in case utility programs get built using a different setting for that */
| 235 | not used when MONITOR_HEAP is enabled, but included unconditionally |
| 236 | in case utility programs get built using a different setting for that */ |
| 237 | char * |
| 238 | dupstr(const char *string) |
| 239 | { |
| 240 | size_t len = strlen(string); |
| 241 | |
| 242 | /* make sure len+1 doesn't overflow plain unsigned (for alloc()) */ |
| 243 | if (len > (unsigned) (~0U - 1U)) |
| 244 | panic("dupstr: string length overflow"); |
| 245 | |
| 246 | return strcpy((char *) alloc(len + 1), string); |
| 247 | } |
| 248 | |
| 249 | #if 0 /* suppress this; if included, it will need a MONITOR_HEAP edition */ |
| 250 |
no test coverage detected