strdup() which uses our alloc() rather than libc's malloc(), with caller tracking */
| 216 | /* strdup() which uses our alloc() rather than libc's malloc(), |
| 217 | with caller tracking */ |
| 218 | char * |
| 219 | nhdupstr(const char *string, const char *file, int line) |
| 220 | { |
| 221 | /* we've got some info about the caller, so use it instead of __func__ */ |
| 222 | unsigned len = FITSuint_(strlen(string), file, line); |
| 223 | |
| 224 | if (FITSuint_(len + 1, file, line) < len) |
| 225 | panic("nhdupstr: string length overflow, line %d of %s", |
| 226 | line, file); |
| 227 | |
| 228 | return strcpy((char *) nhalloc(len + 1, file, line), string); |
| 229 | } |
| 230 | #undef dupstr |
| 231 | |
| 232 | #endif /* MONITOR_HEAP */ |